Deleted Added
full compact
getcap.c (55837) getcap.c (56698)
1/*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Casey Leedom of Lawrence Livermore National Laboratory.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 19 unchanged lines hidden (view full) ---

28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
1/*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Casey Leedom of Lawrence Livermore National Laboratory.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 19 unchanged lines hidden (view full) ---

28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * $FreeBSD: head/lib/libc/gen/getcap.c 55837 2000-01-12 09:23:48Z jasone $
36 * $FreeBSD: head/lib/libc/gen/getcap.c 56698 2000-01-27 23:07:25Z jasone $
37 */
38
39#if defined(LIBC_SCCS) && !defined(lint)
40static char sccsid[] = "@(#)getcap.c 8.3 (Berkeley) 3/25/94";
41#endif /* LIBC_SCCS and not lint */
42
43#include <sys/types.h>
44

--- 218 unchanged lines hidden (view full) ---

263 if (capdbp->close(capdbp) < 0) {
264 free(cbuf);
265 return (-2);
266 }
267 *len = clen;
268 *cap = cbuf;
269 return (retval);
270 } else {
37 */
38
39#if defined(LIBC_SCCS) && !defined(lint)
40static char sccsid[] = "@(#)getcap.c 8.3 (Berkeley) 3/25/94";
41#endif /* LIBC_SCCS and not lint */
42
43#include <sys/types.h>
44

--- 218 unchanged lines hidden (view full) ---

263 if (capdbp->close(capdbp) < 0) {
264 free(cbuf);
265 return (-2);
266 }
267 *len = clen;
268 *cap = cbuf;
269 return (retval);
270 } else {
271 fd = _libc_open(*db_p, O_RDONLY, 0);
271 fd = _open(*db_p, O_RDONLY, 0);
272 if (fd < 0)
273 continue;
274 myfd = 1;
275 }
276 }
277 /*
278 * Find the requested capability record ...
279 */

--- 18 unchanged lines hidden (view full) ---

298 * Read in a line implementing (\, newline)
299 * line continuation.
300 */
301 rp = record;
302 for (;;) {
303 if (bp >= b_end) {
304 int n;
305
272 if (fd < 0)
273 continue;
274 myfd = 1;
275 }
276 }
277 /*
278 * Find the requested capability record ...
279 */

--- 18 unchanged lines hidden (view full) ---

298 * Read in a line implementing (\, newline)
299 * line continuation.
300 */
301 rp = record;
302 for (;;) {
303 if (bp >= b_end) {
304 int n;
305
306 n = _libc_read(fd, buf, sizeof(buf));
306 n = _read(fd, buf, sizeof(buf));
307 if (n <= 0) {
308 if (myfd)
307 if (n <= 0) {
308 if (myfd)
309 (void)_libc_close(fd);
309 (void)_close(fd);
310 if (n < 0) {
311 free(record);
312 return (-2);
313 } else {
314 fd = -1;
315 eof = 1;
316 break;
317 }

--- 22 unchanged lines hidden (view full) ---

340 size_t newsize;
341
342 pos = rp - record;
343 newsize = r_end - record + BFRAG;
344 record = reallocf(record, newsize);
345 if (record == NULL) {
346 errno = ENOMEM;
347 if (myfd)
310 if (n < 0) {
311 free(record);
312 return (-2);
313 } else {
314 fd = -1;
315 eof = 1;
316 break;
317 }

--- 22 unchanged lines hidden (view full) ---

340 size_t newsize;
341
342 pos = rp - record;
343 newsize = r_end - record + BFRAG;
344 record = reallocf(record, newsize);
345 if (record == NULL) {
346 errno = ENOMEM;
347 if (myfd)
348 (void)_libc_close(fd);
348 (void)_close(fd);
349 return (-2);
350 }
351 r_end = record + newsize;
352 rp = record + pos;
353 }
354 }
355 /* loop invariant let's us do this */
356 *rp++ = '\0';

--- 73 unchanged lines hidden (view full) ---

430 iret = getent(&icap, &ilen, db_p, fd, tc, depth+1,
431 NULL);
432 newicap = icap; /* Put into a register. */
433 newilen = ilen;
434 if (iret != 0) {
435 /* an error */
436 if (iret < -1) {
437 if (myfd)
349 return (-2);
350 }
351 r_end = record + newsize;
352 rp = record + pos;
353 }
354 }
355 /* loop invariant let's us do this */
356 *rp++ = '\0';

--- 73 unchanged lines hidden (view full) ---

430 iret = getent(&icap, &ilen, db_p, fd, tc, depth+1,
431 NULL);
432 newicap = icap; /* Put into a register. */
433 newilen = ilen;
434 if (iret != 0) {
435 /* an error */
436 if (iret < -1) {
437 if (myfd)
438 (void)_libc_close(fd);
438 (void)_close(fd);
439 free(record);
440 return (iret);
441 }
442 if (iret == 1)
443 tc_not_resolved = 1;
444 /* couldn't resolve tc */
445 if (iret == -1) {
446 *(s - 1) = ':';

--- 33 unchanged lines hidden (view full) ---

480 pos = rp - record;
481 newsize = r_end - record + diff + BFRAG;
482 tcpos = tcstart - record;
483 tcposend = tcend - record;
484 record = reallocf(record, newsize);
485 if (record == NULL) {
486 errno = ENOMEM;
487 if (myfd)
439 free(record);
440 return (iret);
441 }
442 if (iret == 1)
443 tc_not_resolved = 1;
444 /* couldn't resolve tc */
445 if (iret == -1) {
446 *(s - 1) = ':';

--- 33 unchanged lines hidden (view full) ---

480 pos = rp - record;
481 newsize = r_end - record + diff + BFRAG;
482 tcpos = tcstart - record;
483 tcposend = tcend - record;
484 record = reallocf(record, newsize);
485 if (record == NULL) {
486 errno = ENOMEM;
487 if (myfd)
488 (void)_libc_close(fd);
488 (void)_close(fd);
489 free(icap);
490 return (-2);
491 }
492 r_end = record + newsize;
493 rp = record + pos;
494 tcstart = record + tcpos;
495 tcend = record + tcposend;
496 }

--- 15 unchanged lines hidden (view full) ---

512 }
513
514 }
515 /*
516 * Close file (if we opened it), give back any extra memory, and
517 * return capability, length and success.
518 */
519 if (myfd)
489 free(icap);
490 return (-2);
491 }
492 r_end = record + newsize;
493 rp = record + pos;
494 tcstart = record + tcpos;
495 tcend = record + tcposend;
496 }

--- 15 unchanged lines hidden (view full) ---

512 }
513
514 }
515 /*
516 * Close file (if we opened it), give back any extra memory, and
517 * return capability, length and success.
518 */
519 if (myfd)
520 (void)_libc_close(fd);
520 (void)_close(fd);
521 *len = rp - record - 1; /* don't count NUL */
522 if (r_end > rp)
523 if ((record =
524 reallocf(record, (size_t)(rp - record))) == NULL) {
525 errno = ENOMEM;
526 return (-2);
527 }
528

--- 518 unchanged lines hidden ---
521 *len = rp - record - 1; /* don't count NUL */
522 if (r_end > rp)
523 if ((record =
524 reallocf(record, (size_t)(rp - record))) == NULL) {
525 errno = ENOMEM;
526 return (-2);
527 }
528

--- 518 unchanged lines hidden ---