Correct handling of overflow.

This commit is contained in:
Ulrich Drepper 1997-12-24 21:07:25 +00:00
parent b1aa8394ef
commit c0f9cb02b8
9 changed files with 94 additions and 129 deletions

View File

@ -165,7 +165,7 @@ internal_nis_getetherent_r (struct ether *eth, char *buffer, size_t buflen)
++p;
parse_res = _nss_files_parse_etherent (p, eth, data, buflen);
if (!parse_res && errno == ERANGE)
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
}
while (!parse_res);
@ -230,15 +230,12 @@ _nss_nis_gethostton_r (const char *name, struct ether *eth,
parse_res = _nss_files_parse_etherent (p, eth, data, buflen);
if (!parse_res)
{
if (errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else
return NSS_STATUS_NOTFOUND;
}
else
return NSS_STATUS_SUCCESS;
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else if (parse_res == 0)
return NSS_STATUS_NOTFOUND;
return NSS_STATUS_SUCCESS;
}
enum nss_status
@ -293,13 +290,10 @@ _nss_nis_getntohost_r (struct ether_addr *addr, struct ether *eth,
parse_res = _nss_files_parse_etherent (p, eth, data, buflen);
if (!parse_res)
{
if (errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else
return NSS_STATUS_NOTFOUND;
}
else
return NSS_STATUS_SUCCESS;
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else if (parse_res == 0)
return NSS_STATUS_NOTFOUND;
return NSS_STATUS_SUCCESS;
}

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
@ -122,7 +122,7 @@ internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen)
free (result);
parse_res = _nss_files_parse_grent (p, grp, data, buflen);
if (!parse_res && errno == ERANGE)
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
free (oldkey);
@ -192,15 +192,12 @@ _nss_nis_getgrnam_r (const char *name, struct group *grp,
parse_res = _nss_files_parse_grent (p, grp, data, buflen);
if (!parse_res)
{
if (errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else
return NSS_STATUS_NOTFOUND;
}
else
return NSS_STATUS_SUCCESS;
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else if (parse_res == 0)
return NSS_STATUS_NOTFOUND;
return NSS_STATUS_SUCCESS;
}
enum nss_status
@ -243,13 +240,10 @@ _nss_nis_getgrgid_r (gid_t gid, struct group *grp,
parse_res = _nss_files_parse_grent (p, grp, data, buflen);
if (!parse_res)
{
if (errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else
return NSS_STATUS_NOTFOUND;
}
else
return NSS_STATUS_SUCCESS;
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else if (parse_res == 0)
return NSS_STATUS_NOTFOUND;
return NSS_STATUS_SUCCESS;
}

View File

@ -212,7 +212,7 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer,
free (result);
parse_res = parse_line (p, host, data, buflen);
if (!parse_res && errno == ERANGE)
if (parse_res == -1 && errno == ERANGE)
{
*h_errnop = NETDB_INTERNAL;;
return NSS_STATUS_TRYAGAIN;
@ -299,18 +299,16 @@ _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host,
parse_res = parse_line (p, host, data, buflen);
if (!parse_res || host->h_addrtype != af)
if (parse_res == -1 && errno == ERANGE)
{
if (!parse_res && errno == ERANGE)
{
*h_errnop = NETDB_INTERNAL;
return NSS_STATUS_TRYAGAIN;
}
else
{
*h_errnop = HOST_NOT_FOUND;
return NSS_STATUS_NOTFOUND;
}
*h_errnop = NETDB_INTERNAL;
return NSS_STATUS_TRYAGAIN;
}
if (parse_res == 0 || host->h_addrtype != af)
{
*h_errnop = HOST_NOT_FOUND;
return NSS_STATUS_NOTFOUND;
}
*h_errnop = NETDB_SUCCESS;
@ -390,18 +388,15 @@ _nss_nis_gethostbyaddr_r (char *addr, int addrlen, int type,
parse_res = parse_line (p, host, data, buflen);
if (!parse_res)
if (parse_res == -1 && errno == ERANGE)
{
if (errno == ERANGE)
{
*h_errnop = NETDB_INTERNAL;
return NSS_STATUS_TRYAGAIN;
}
else
{
*h_errnop = HOST_NOT_FOUND;
return NSS_STATUS_NOTFOUND;
}
*h_errnop = NETDB_INTERNAL;
return NSS_STATUS_TRYAGAIN;
}
else if (parse_res == 0)
{
*h_errnop = HOST_NOT_FOUND;
return NSS_STATUS_NOTFOUND;
}
*h_errnop = NETDB_SUCCESS;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
@ -127,7 +127,7 @@ internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen,
free (result);
parse_res = _nss_files_parse_netent (p, net, data, buflen);
if (!parse_res && errno == ERANGE)
if (parse_res == -1 && errno == ERANGE)
{
*herrnop = NETDB_INTERNAL;
return NSS_STATUS_TRYAGAIN;
@ -206,10 +206,10 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net,
parse_res = _nss_files_parse_netent (p, net, data, buflen);
if (!parse_res)
if (parse_res <= 0)
{
*herrnop = NETDB_INTERNAL;
if (errno == ERANGE)
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else
return NSS_STATUS_NOTFOUND;
@ -286,10 +286,10 @@ _nss_nis_getnetbyaddr_r (unsigned long addr, int type, struct netent *net,
parse_res = _nss_files_parse_netent (p, net, data, buflen);
if (!parse_res)
if (parse_res <= 0)
{
*herrnop = NETDB_INTERNAL;
if (errno == ERANGE)
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else
return NSS_STATUS_NOTFOUND;

View File

@ -158,7 +158,7 @@ internal_nis_getprotoent_r (struct protoent *proto,
++p;
parse_res = _nss_files_parse_protoent (p, proto, data, buflen);
if (!parse_res && errno == ERANGE)
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
}
while (!parse_res);
@ -223,15 +223,12 @@ _nss_nis_getprotobyname_r (const char *name, struct protoent *proto,
parse_res = _nss_files_parse_protoent (p, proto, data, buflen);
if (!parse_res)
{
if (errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else
return NSS_STATUS_NOTFOUND;
}
else
return NSS_STATUS_SUCCESS;
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else if (parse_res == 0)
return NSS_STATUS_NOTFOUND;
return NSS_STATUS_SUCCESS;
}
enum nss_status
@ -274,13 +271,10 @@ _nss_nis_getprotobynumber_r (int number, struct protoent *proto,
parse_res = _nss_files_parse_protoent (p, proto, data, buflen);
if (!parse_res)
{
if (errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else
return NSS_STATUS_NOTFOUND;
}
else
return NSS_STATUS_SUCCESS;
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else if (parse_res == 0)
return NSS_STATUS_NOTFOUND;
return NSS_STATUS_SUCCESS;
}

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
@ -122,7 +122,7 @@ internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen)
free (result);
parse_res = _nss_files_parse_pwent (p, pwd, data, buflen);
if (!parse_res && errno == ERANGE)
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
free (oldkey);
@ -192,15 +192,12 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd,
parse_res = _nss_files_parse_pwent (p, pwd, data, buflen);
if (!parse_res)
{
if (errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else
return NSS_STATUS_NOTFOUND;
}
else
return NSS_STATUS_SUCCESS;
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else if (parse_res == 0)
return NSS_STATUS_NOTFOUND;
return NSS_STATUS_SUCCESS;
}
enum nss_status
@ -243,13 +240,10 @@ _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd,
parse_res = _nss_files_parse_pwent (p, pwd, data, buflen);
if (!parse_res)
{
if (errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else
return NSS_STATUS_NOTFOUND;
}
else
return NSS_STATUS_SUCCESS;
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else if (parse_res == 0)
return NSS_STATUS_NOTFOUND;
return NSS_STATUS_SUCCESS;
}

View File

@ -174,7 +174,7 @@ internal_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen,
++p;
parse_res = _nss_files_parse_rpcent (p, rpc, pdata, buflen);
if (!parse_res && errno == ERANGE)
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
}
while (!parse_res);
@ -286,13 +286,10 @@ _nss_nis_getrpcbynumber_r (int number, struct rpcent *rpc,
parse_res = _nss_files_parse_rpcent (p, rpc, data, buflen);
if (!parse_res)
{
if (errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else
return NSS_STATUS_NOTFOUND;
}
else
return NSS_STATUS_SUCCESS;
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else if (parse_res == 0)
return NSS_STATUS_NOTFOUND;
return NSS_STATUS_SUCCESS;
}

View File

@ -174,7 +174,7 @@ internal_nis_getservent_r (struct servent *serv, char *buffer,
++p;
parse_res = _nss_files_parse_servent (p, serv, buffer, buflen);
if (!parse_res && errno == ERANGE)
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
}
while (!parse_res);

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
@ -122,7 +122,7 @@ internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen)
free (result);
parse_res = _nss_files_parse_spent (p, sp, data, buflen);
if (!parse_res && errno == ERANGE)
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
free (oldkey);
@ -192,13 +192,10 @@ _nss_nis_getspnam_r (const char *name, struct spwd *sp,
parse_res = _nss_files_parse_spent (p, sp, data, buflen);
if (!parse_res)
{
if (errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else
return NSS_STATUS_NOTFOUND;
}
else
return NSS_STATUS_SUCCESS;
if (parse_res == -1 && errno == ERANGE)
return NSS_STATUS_TRYAGAIN;
else if (parse_res == 0)
return NSS_STATUS_NOTFOUND;
return NSS_STATUS_SUCCESS;
}