View | Details | Raw Unified | Return to bug 252094 | Differences between
and this patch

Collapse All | Expand All

(-)getgrent.c (-12 / +18 lines)
Lines 869-884 Link Here
869
		}
869
		}
870
		fresh = 1;
870
		fresh = 1;
871
	}
871
	}
872
	if (how == nss_lt_all)
872
	if (how == nss_lt_all) {
873
		stayopen = 1;
873
		stayopen = 1;
874
	else {
874
		pos = ftello(st->fp);
875
		if (!fresh)
875
	} else {
876
		if (!fresh) {
877
			pos = ftello(st->fp);
876
			rewind(st->fp);
878
			rewind(st->fp);
879
		}
877
		stayopen = st->stayopen;
880
		stayopen = st->stayopen;
878
	}
881
	}
879
	rv = NS_NOTFOUND;
882
	rv = NS_NOTFOUND;
880
	if (stayopen)
881
		pos = ftello(st->fp);
882
	while ((line = fgetln(st->fp, &linesize)) != NULL) {
883
	while ((line = fgetln(st->fp, &linesize)) != NULL) {
883
		if (line[linesize-1] == '\n')
884
		if (line[linesize-1] == '\n')
884
			linesize--;
885
			linesize--;
Lines 900-906 Link Here
900
		    &buffer[linesize + 1], bufsize - linesize - 1, errnop);
901
		    &buffer[linesize + 1], bufsize - linesize - 1, errnop);
901
		if (rv & NS_TERMINATE)
902
		if (rv & NS_TERMINATE)
902
			break;
903
			break;
903
		if (stayopen)
904
		if (how == nss_lt_all)
904
			pos = ftello(st->fp);
905
			pos = ftello(st->fp);
905
	}
906
	}
906
	if (st->fp != NULL && !stayopen) {
907
	if (st->fp != NULL && !stayopen) {
Lines 907-912 Link Here
907
		fclose(st->fp);
908
		fclose(st->fp);
908
		st->fp = NULL;
909
		st->fp = NULL;
909
	}
910
	}
911
	if (st->ftp != NULL && how != nss_lt_all)
912
		fseeko(st->fp, pos, SEEK_SET);
910
	if (rv == NS_SUCCESS && retval != NULL)
913
	if (rv == NS_SUCCESS && retval != NULL)
911
		*(struct group **)retval = grp;
914
		*(struct group **)retval = grp;
912
	else if (rv == NS_RETURN && *errnop == ERANGE && st->fp != NULL)
915
	else if (rv == NS_RETURN && *errnop == ERANGE && st->fp != NULL)
Lines 1351-1361 Link Here
1351
		}
1354
		}
1352
		fresh = 1;
1355
		fresh = 1;
1353
	}
1356
	}
1354
	if (how == nss_lt_all)
1357
	if (how == nss_lt_all) {
1355
		stayopen = 1;
1358
		stayopen = 1;
1356
	else {
1359
		pos = ftello(st->fp);
1357
		if (!fresh)
1360
	} else {
1361
		if (!fresh) {
1362
			pos = ftello(st->fp);
1358
			rewind(st->fp);
1363
			rewind(st->fp);
1364
		}
1359
		stayopen = st->stayopen;
1365
		stayopen = st->stayopen;
1360
	}
1366
	}
1361
docompat:
1367
docompat:
Lines 1418-1425 Link Here
1418
		break;
1424
		break;
1419
	}
1425
	}
1420
	rv = NS_NOTFOUND;
1426
	rv = NS_NOTFOUND;
1421
	if (stayopen)
1422
		pos = ftello(st->fp);
1423
	while ((line = fgetln(st->fp, &linesize)) != NULL) {
1427
	while ((line = fgetln(st->fp, &linesize)) != NULL) {
1424
		if (line[linesize-1] == '\n')
1428
		if (line[linesize-1] == '\n')
1425
			linesize--;
1429
			linesize--;
Lines 1460-1466 Link Here
1460
		    &buffer[linesize + 1], bufsize - linesize - 1, errnop);
1464
		    &buffer[linesize + 1], bufsize - linesize - 1, errnop);
1461
		if (rv & NS_TERMINATE)
1465
		if (rv & NS_TERMINATE)
1462
			break;
1466
			break;
1463
		if (stayopen)
1467
		if (how == nss_lt_all)
1464
			pos = ftello(st->fp);
1468
			pos = ftello(st->fp);
1465
	}
1469
	}
1466
fin:
1470
fin:
Lines 1468-1473 Link Here
1468
		fclose(st->fp);
1472
		fclose(st->fp);
1469
		st->fp = NULL;
1473
		st->fp = NULL;
1470
	}
1474
	}
1475
	if (st->fp != NULL && how != nss_lt_all)
1476
		fseeko(st->fp, pos, SEEK_SET);
1471
	if (rv == NS_SUCCESS && retval != NULL)
1477
	if (rv == NS_SUCCESS && retval != NULL)
1472
		*(struct group **)retval = grp;
1478
		*(struct group **)retval = grp;
1473
	else if (rv == NS_RETURN && *errnop == ERANGE && st->fp != NULL)
1479
	else if (rv == NS_RETURN && *errnop == ERANGE && st->fp != NULL)

Return to bug 252094