fa.openbsd.tech
[Top] [All Lists]

bin/date diff

Subject: bin/date diff
From: Gleydson Soares <gsoares@xxxxxxxxx>
Date: Fri, 25 Jul 2008 18:12:05 UTC
Newsgroups: fa.openbsd.tech

- only the superuser can bind to a privileged port through bindresvport().
- style(9).
Index: netdate.c
===================================================================
RCS file: /cvs/src/bin/date/netdate.c,v
retrieving revision 1.16
diff -u -r1.16 netdate.c
--- netdate.c   25 Apr 2006 15:41:07 -0000      1.16
+++ netdate.c   25 Jul 2008 17:43:37 -0000
@@ -103,7 +103,7 @@
        memset(&sin, 0, sizeof(sin));
        sin.sin_len = sizeof(struct sockaddr_in);
        sin.sin_family = AF_INET;
-       if (bindresvport(s, &sin) < 0) {
+       if ((getuid() == 0) && (bindresvport(s, &sin) < 0)) {
                warnx("all ports in use");
                goto bad;
        }
Index: date.c
===================================================================
RCS file: /cvs/src/bin/date/date.c,v
retrieving revision 1.31
diff -u -r1.31 date.c
--- date.c      28 Dec 2007 19:17:28 -0000      1.31
+++ date.c      25 Jul 2008 17:43:53 -0000
@@ -70,7 +70,7 @@
 
 static void setthetime(char *);
 static void badformat(void);
-static void usage(void);
+static __dead void usage(void);
 
 int
 main(int argc, char *argv[])
@@ -261,7 +261,7 @@
        usage();
 }
 
-static void
+static __dead void
 usage(void)
 {
        (void)fprintf(stderr,


<Prev in Thread] Current Thread [Next in Thread>