commit 972fc456a76b659994f00216313cd5550304823a
parent 70eafcdcd0531abc07b006597bd23b93695d2e37
Author: Jordan Ritter <jpr5@darkridge.com>
Date: Fri, 14 May 2004 19:30:56 +0000
added quick check to drop_privs to report failure of getpwnam().
doesn't affect security; ngrep would have crashed anyway trying to
deref the struct.
Diffstat:
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/ngrep.c b/ngrep.c
@@ -54,8 +54,8 @@
#include <netinet/udp.h>
#include <netinet/ip_icmp.h>
-#include <pcap.h>
#include <net/bpf.h>
+#include <pcap.h>
#include <stdlib.h>
#include <string.h>
@@ -393,6 +393,8 @@ int main(int argc, char **argv) {
while (*s)
*s++ = tolower(*s);
+ printf("match_data = %s\n", match_data);
+
} else pattern.translate = NULL;
#endif
@@ -1005,6 +1007,11 @@ void drop_privs(void) {
gid_t newgid = pw->pw_uid, oldgid = getegid();
uid_t newuid = pw->pw_gid, olduid = geteuid();
+ if (!pw) {
+ perror("attempt to drop privileges failed: getpwnam failed");
+ clean_exit(-1);
+ }
+
if (!olduid)
setgroups(1, &newgid);