with a newline.
ok jca@
-/* $OpenBSD: asr.c,v 1.36 2015/05/26 19:28:57 eric Exp $ */
+/* $OpenBSD: asr.c,v 1.37 2015/05/29 08:49:37 eric Exp $ */
/*
* Copyright (c) 2010-2012 Eric Faurot <eric@openbsd.org>
*
* size "ntoken" and returns the number of token on the line.
*/
int
-asr_parse_namedb_line(FILE *file, char **tokens, int ntoken)
+asr_parse_namedb_line(FILE *file, char **tokens, int ntoken, char *lbuf, size_t sz)
{
size_t len;
char *buf;
if ((buf = fgetln(file, &len)) == NULL)
return (-1);
+ if (len >= sz)
+ goto again;
+
if (buf[len - 1] == '\n')
len--;
+ else {
+ memcpy(lbuf, buf, len);
+ buf = lbuf;
+ }
buf[len] = '\0';
buf[strcspn(buf, "#")] = '\0';
-/* $OpenBSD: asr_private.h,v 1.28 2015/05/26 19:28:57 eric Exp $ */
+/* $OpenBSD: asr_private.h,v 1.29 2015/05/29 08:49:37 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
size_t asr_make_fqdn(const char *, const char *, char *, size_t);
char *asr_strdname(const char *, char *, size_t);
int asr_iter_db(struct asr_query *);
-int asr_parse_namedb_line(FILE *, char **, int);
+int asr_parse_namedb_line(FILE *, char **, int, char *, size_t);
char *asr_hostalias(struct asr_ctx *, const char *, char *, size_t);
/* *_async.c */
-/* $OpenBSD: getaddrinfo_async.c,v 1.39 2015/05/26 19:28:57 eric Exp $ */
+/* $OpenBSD: getaddrinfo_async.c,v 1.40 2015/05/29 08:49:37 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
static int
addrinfo_from_file(struct asr_query *as, int family, FILE *f)
{
- char *tokens[MAXTOKEN], *c;
+ char *tokens[MAXTOKEN], *c, buf[BUFSIZ + 1];
int n, i;
union {
struct sockaddr sa;
} u;
for (;;) {
- n = asr_parse_namedb_line(f, tokens, MAXTOKEN);
+ n = asr_parse_namedb_line(f, tokens, MAXTOKEN, buf, sizeof(buf));
if (n == -1)
break; /* ignore errors reading the file */
-/* $OpenBSD: gethostnamadr_async.c,v 1.36 2015/05/26 19:28:57 eric Exp $ */
+/* $OpenBSD: gethostnamadr_async.c,v 1.37 2015/05/29 08:49:37 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
hostent_file_match(FILE *f, int reqtype, int family, const char *data,
int datalen)
{
- char *tokens[MAXTOKEN], addr[16];
+ char *tokens[MAXTOKEN], addr[16], buf[BUFSIZ + 1];
struct hostent_ext *h;
int n, i;
for (;;) {
- n = asr_parse_namedb_line(f, tokens, MAXTOKEN);
+ n = asr_parse_namedb_line(f, tokens, MAXTOKEN, buf, sizeof(buf));
if (n == -1) {
errno = 0; /* ignore errors reading the file */
return (NULL);
-/* $OpenBSD: getnetnamadr_async.c,v 1.19 2014/11/02 13:59:16 eric Exp $ */
+/* $OpenBSD: getnetnamadr_async.c,v 1.20 2015/05/29 08:49:37 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
netent_file_match(FILE *f, int reqtype, const char *data)
{
struct netent_ext *e;
- char *tokens[MAXTOKEN];
+ char *tokens[MAXTOKEN], buf[BUFSIZ + 1];
int n, i;
in_addr_t net;
for (;;) {
- n = asr_parse_namedb_line(f, tokens, MAXTOKEN);
+ n = asr_parse_namedb_line(f, tokens, MAXTOKEN, buf, sizeof(buf));
if (n == -1) {
errno = 0; /* ignore errors reading the file */
return (NULL);