From 54028e403ef41769e79cdff5089fad9a74dfa154 Mon Sep 17 00:00:00 2001 From: George Koehler Date: Sat, 28 Oct 2017 14:25:39 -0400 Subject: [PATCH] Delete unused misc/getpw.c from libc. @hexcoder- reported in https://github.com/davidgiven/ack/issues/57 that our getpw() has bugs. I don't fix these bugs, because Illumos and Linux manual pages say that getpw() is obsolete. The function can overflow its buffer, so it is never safe to use. Our libc did not build getpw(). --- lang/cem/libcc.ansi/misc/getpw.c | 38 -------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 lang/cem/libcc.ansi/misc/getpw.c diff --git a/lang/cem/libcc.ansi/misc/getpw.c b/lang/cem/libcc.ansi/misc/getpw.c deleted file mode 100644 index a4166e8c9..000000000 --- a/lang/cem/libcc.ansi/misc/getpw.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * getpw - get a password from the password file - */ -/* $Id$ */ - -#include - -getpw(int uid, char buf[]) -{ - register FILE *pwf; - register int ch, i; - register char *bp; - - pwf = fopen("/etc/passwd", "r"); - if (pwf == NULL) return(1); - - for (;;) { - bp = buf; - while ((ch = getc(pwf)) != '\n') { - if (ch == EOF) return 1; - *bp++ = ch; - } - *bp++ = '\0'; - bp = buf; - for (i = 2; i; i--) { - while ((ch = *bp++) != ':') { - if(ch = '\0') return 1; - } - } - i = 0; - while ((ch = *bp++) != ':') { - if (ch < '0' || ch > '9') return 1; - i = i * 10 + (ch - '0'); - } - if (i == uid) return(0); - } - /*NOTREACHED*/ -}