summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorghelmer <ghelmer@FreeBSD.org>2012-01-10 19:54:53 +0000
committerghelmer <ghelmer@FreeBSD.org>2012-01-10 19:54:53 +0000
commita2d41d9cca5dd4366eee8381829bc99a21fe3503 (patch)
treeb085a7f855eccc5b3405c8fb0a11654ea0b9ddab /lib/libc
parent9446d41409ef9748c6f20034374a472d777b7135 (diff)
downloadFreeBSD-src-a2d41d9cca5dd4366eee8381829bc99a21fe3503.zip
FreeBSD-src-a2d41d9cca5dd4366eee8381829bc99a21fe3503.tar.gz
Revert unintentional commit of changes to getnetgrent.c.
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/getnetgrent.c41
1 files changed, 13 insertions, 28 deletions
diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c
index bbd1495..ca75d9b 100644
--- a/lib/libc/gen/getnetgrent.c
+++ b/lib/libc/gen/getnetgrent.c
@@ -203,7 +203,9 @@ setnetgrent(const char *group)
if (parse_netgrp(group))
endnetgrent();
else {
- grouphead.grname = strdup(group);
+ grouphead.grname = (char *)
+ malloc(strlen(group) + 1);
+ strcpy(grouphead.grname, group);
}
if (netf)
fclose(netf);
@@ -415,7 +417,7 @@ static int
parse_netgrp(const char *group)
{
char *spos, *epos;
- int len, strpos, freepos;
+ int len, strpos;
#ifdef DEBUG
int fields;
#endif
@@ -452,9 +454,9 @@ parse_netgrp(const char *group)
while (pos != NULL && *pos != '\0') {
if (*pos == '(') {
grp = (struct netgrp *)malloc(sizeof (struct netgrp));
- if (grp == NULL)
- return(1);
bzero((char *)grp, sizeof (struct netgrp));
+ grp->ng_next = grouphead.gr;
+ grouphead.gr = grp;
pos++;
gpos = strsep(&pos, ")");
#ifdef DEBUG
@@ -475,13 +477,6 @@ parse_netgrp(const char *group)
if (len > 0) {
grp->ng_str[strpos] = (char *)
malloc(len + 1);
- if (grp->ng_str[strpos] == NULL) {
- for (freepos = 0; freepos < strpos; freepos++)
- if (grp->ng_str[freepos] != NULL)
- free(grp->ng_str[freepos]);
- free(grp);
- return(1);
- }
bcopy(spos, grp->ng_str[strpos],
len + 1);
}
@@ -495,8 +490,6 @@ parse_netgrp(const char *group)
grp->ng_str[strpos] = NULL;
}
}
- grp->ng_next = grouphead.gr;
- grouphead.gr = grp;
#ifdef DEBUG
/*
* Note: on other platforms, malformed netgroup
@@ -533,7 +526,7 @@ parse_netgrp(const char *group)
static struct linelist *
read_for_group(const char *group)
{
- char *pos, *spos, *linep;
+ char *pos, *spos, *linep, *olinep;
int len, olen;
int cont;
struct linelist *lp;
@@ -541,7 +534,6 @@ read_for_group(const char *group)
#ifdef YP
char *result;
int resultlen;
- linep = NULL;
while (_netgr_yp_enabled || fgets(line, LINSIZ, netf) != NULL) {
if (_netgr_yp_enabled) {
@@ -562,7 +554,6 @@ read_for_group(const char *group)
free(result);
}
#else
- linep = NULL;
while (fgets(line, LINSIZ, netf) != NULL) {
#endif
pos = (char *)&line;
@@ -585,14 +576,8 @@ read_for_group(const char *group)
pos++;
if (*pos != '\n' && *pos != '\0') {
lp = (struct linelist *)malloc(sizeof (*lp));
- if (lp == NULL)
- return(NULL);
lp->l_parsed = 0;
lp->l_groupname = (char *)malloc(len + 1);
- if (lp->l_groupname == NULL) {
- free(lp);
- return(NULL);
- }
bcopy(spos, lp->l_groupname, len);
*(lp->l_groupname + len) = '\0';
len = strlen(pos);
@@ -610,15 +595,15 @@ read_for_group(const char *group)
} else
cont = 0;
if (len > 0) {
- linep = (char *)reallocf(linep, olen + len + 1);
- if (linep == NULL) {
- free(lp->l_groupname);
- free(lp);
- return(NULL);
+ linep = (char *)malloc(olen + len + 1);
+ 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)) {
@@ -649,5 +634,5 @@ read_for_group(const char *group)
*/
rewind(netf);
#endif
- return (NULL);
+ return ((struct linelist *)0);
}
OpenPOWER on IntegriCloud