View | Details | Raw Unified | Return to bug 83340
Collapse All | Expand All

(-)lib/libc/gen/getnetgrent.c (-10 / +18 lines)
Lines 207-215 Link Here
207
			if (parse_netgrp(group))
207
			if (parse_netgrp(group))
208
				endnetgrent();
208
				endnetgrent();
209
			else {
209
			else {
210
				grouphead.grname = (char *)
210
				grouphead.grname = strdup(group);
211
					malloc(strlen(group) + 1);
212
				strcpy(grouphead.grname, group);
213
			}
211
			}
214
			if (netf)
212
			if (netf)
215
				fclose(netf);
213
				fclose(netf);
Lines 448-453 Link Here
448
	while (pos != NULL && *pos != '\0') {
446
	while (pos != NULL && *pos != '\0') {
449
		if (*pos == '(') {
447
		if (*pos == '(') {
450
			grp = (struct netgrp *)malloc(sizeof (struct netgrp));
448
			grp = (struct netgrp *)malloc(sizeof (struct netgrp));
449
			if (grp == NULL)
450
				return(1);
451
			bzero((char *)grp, sizeof (struct netgrp));
451
			bzero((char *)grp, sizeof (struct netgrp));
452
			grp->ng_next = grouphead.gr;
452
			grp->ng_next = grouphead.gr;
453
			grouphead.gr = grp;
453
			grouphead.gr = grp;
Lines 471-476 Link Here
471
					if (len > 0) {
471
					if (len > 0) {
472
						grp->ng_str[strpos] =  (char *)
472
						grp->ng_str[strpos] =  (char *)
473
							malloc(len + 1);
473
							malloc(len + 1);
474
						if (grp->ng_str[strpos] == NULL)
475
							return(1);
474
						bcopy(spos, grp->ng_str[strpos],
476
						bcopy(spos, grp->ng_str[strpos],
475
							len + 1);
477
							len + 1);
476
					}
478
					}
Lines 520-526 Link Here
520
static struct linelist *
522
static struct linelist *
521
read_for_group(const char *group)
523
read_for_group(const char *group)
522
{
524
{
523
	char *pos, *spos, *linep, *olinep;
525
	char *pos, *spos, *linep;
524
	int len, olen;
526
	int len, olen;
525
	int cont;
527
	int cont;
526
	struct linelist *lp;
528
	struct linelist *lp;
Lines 570-577 Link Here
570
			pos++;
572
			pos++;
571
		if (*pos != '\n' && *pos != '\0') {
573
		if (*pos != '\n' && *pos != '\0') {
572
			lp = (struct linelist *)malloc(sizeof (*lp));
574
			lp = (struct linelist *)malloc(sizeof (*lp));
575
			if (lp == NULL) 
576
				return(NULL);
573
			lp->l_parsed = 0;
577
			lp->l_parsed = 0;
574
			lp->l_groupname = (char *)malloc(len + 1);
578
			lp->l_groupname = (char *)malloc(len + 1);
579
			if (lp->l_groupname == NULL) {
580
				free(lp);
581
				return(NULL);
582
			}
575
			bcopy(spos, lp->l_groupname, len);
583
			bcopy(spos, lp->l_groupname, len);
576
			*(lp->l_groupname + len) = '\0';
584
			*(lp->l_groupname + len) = '\0';
577
			len = strlen(pos);
585
			len = strlen(pos);
Lines 589-603 Link Here
589
				} else
597
				} else
590
					cont = 0;
598
					cont = 0;
591
				if (len > 0) {
599
				if (len > 0) {
592
					linep = (char *)malloc(olen + len + 1);
600
					linep = (char *)reallocf(linep, olen + len + 1);
593
					if (olen > 0) {
601
					if (linep == NULL) {
594
						bcopy(olinep, linep, olen);
602
						free(lp->l_groupname);
595
						free(olinep);
603
						free(lp);
604
						return(NULL);
596
					}
605
					}
597
					bcopy(pos, linep + olen, len);
606
					bcopy(pos, linep + olen, len);
598
					olen += len;
607
					olen += len;
599
					*(linep + olen) = '\0';
608
					*(linep + olen) = '\0';
600
					olinep = linep;
601
				}
609
				}
602
				if (cont) {
610
				if (cont) {
603
					if (fgets(line, LINSIZ, netf)) {
611
					if (fgets(line, LINSIZ, netf)) {
Lines 628-632 Link Here
628
	 */
636
	 */
629
	rewind(netf);
637
	rewind(netf);
630
#endif
638
#endif
631
	return ((struct linelist *)0);
639
	return (NULL);
632
}
640
}

Return to bug 83340