svn commit: r237266 - stable/9/lib/libc/gen
Konstantin Belousov
kib at FreeBSD.org
Tue Jun 19 10:06:35 UTC 2012
Author: kib
Date: Tue Jun 19 10:06:34 2012
New Revision: 237266
URL: http://svn.freebsd.org/changeset/base/237266
Log:
MFC r237159:
Fix reading of netgroup(5) file which contains more then one netgroup.
Modified:
stable/9/lib/libc/gen/getnetgrent.c
Directory Properties:
stable/9/lib/libc/ (props changed)
Modified: stable/9/lib/libc/gen/getnetgrent.c
==============================================================================
--- stable/9/lib/libc/gen/getnetgrent.c Tue Jun 19 10:04:36 2012 (r237265)
+++ stable/9/lib/libc/gen/getnetgrent.c Tue Jun 19 10:06:34 2012 (r237266)
@@ -538,7 +538,7 @@ parse_netgrp(const char *group)
static struct linelist *
read_for_group(const char *group)
{
- char *pos, *spos, *linep;
+ char *linep, *olinep, *pos, *spos;
int len, olen;
int cont;
struct linelist *lp;
@@ -615,15 +615,20 @@ read_for_group(const char *group)
} else
cont = 0;
if (len > 0) {
- linep = reallocf(linep, olen + len + 1);
+ linep = malloc(olen + len + 1);
if (linep == NULL) {
free(lp->l_groupname);
free(lp);
return (NULL);
}
+ if (olen > 0) {
+ bcopy(olinep, linep, olen);
+ free(olinep);
+ }
bcopy(pos, linep + olen, len);
olen += len;
*(linep + olen) = '\0';
+ olinep = linep;
}
if (cont) {
if (fgets(line, LINSIZ, netf)) {
More information about the svn-src-stable-9
mailing list