finger: Add a dedicated usage()

2014-07-21 Thread Tristan Le Guern
Hi,

This patch adds a dedicated usage() function to finger(1), like most
other utilities do.

It also removes the unnecessary declaration of optind.

Index: finger.c
===
RCS file: /home/tleguern/proj/perso/cvs/src/usr.bin/finger/finger.c,v
retrieving revision 1.18
diff -u -p -r1.18 finger.c
--- finger.c12 Nov 2009 15:33:21 -  1.18
+++ finger.c21 Jul 2014 10:40:00 -
@@ -68,6 +68,8 @@
 #include finger.h
 #include extern.h

+__dead void usage(void);
+
 time_t now;
 int entries, lflag, sflag, mflag, oflag, pplan, Mflag;
 char tbuf[1024];
@@ -77,8 +79,6 @@ PERSON *phead, *ptail;
 int
 main(int argc, char *argv[])
 {
-   extern int optind;
-   extern char *__progname;
int ch;
char domain[MAXHOSTNAMELEN];
struct stat sb;
@@ -109,10 +109,10 @@ main(int argc, char *argv[])
oflag = 1;  /* office info */
break;
case '?':
+   /* FALLTHROUGH */
default:
-   (void)fprintf(stderr,
-   usage: %s [-hlMmops] [login ...]\n, __progname);
-   exit(1);
+   usage();
+   /* NOTREACHED */
}
argc -= optind;
argv += optind;
@@ -265,3 +265,12 @@ net:   for (pn = nethead; pn; pn = pn-nex
for (pn = phead; pn != NULL; pn = pn-next)
enter_lastlog(pn);
 }
+
+void
+usage(void)
+{
+   (void)fprintf(stderr,
+   usage: %s [-hlMmops] [login ...]\n, getprogname());
+   exit(1);
+}
+



finger: Merge extern.h and finger.h

2014-07-21 Thread Tristan Le Guern
Hi,

This patch merges finger.h and extern.h, has they are always included
together. It also declares static functions as such and removes them
from the prototype list.

Index: finger.c
===
RCS file: /home/tleguern/proj/perso/cvs/src/usr.bin/finger/finger.c,v
retrieving revision 1.18
diff -u -p -r1.18 finger.c
--- finger.c12 Nov 2009 15:33:21 -  1.18
+++ finger.c21 Jul 2014 10:09:46 -
@@ -66,7 +66,9 @@
 #include unistd.h
 #include err.h
 #include finger.h
-#include extern.h
+
+static void loginlist(void);
+static void userlist(int, char **);

 time_t now;
 int entries, lflag, sflag, mflag, oflag, pplan, Mflag;
@@ -158,7 +160,7 @@ main(int argc, char *argv[])
exit(0);
 }

-void
+static void
 loginlist(void)
 {
PERSON *pn;
@@ -184,7 +186,7 @@ loginlist(void)
enter_lastlog(pn);
 }

-void
+static void
 userlist(int argc, char **argv)
 {
int i;
Index: finger.h
===
RCS file: /home/tleguern/proj/perso/cvs/src/usr.bin/finger/finger.h,v
retrieving revision 1.6
diff -u -p -r1.6 finger.h
--- finger.h15 Mar 2004 02:50:29 -  1.6
+++ finger.h21 Jul 2014 10:20:20 -
@@ -77,3 +77,26 @@ typedef struct where {

 extern PERSON *htab[HSIZE];/* the buckets */
 extern PERSON *phead, *ptail;  /* the linked list of all people */
+
+extern time_t now; /* Current time. */
+extern char tbuf[1024];/* Temp buffer for anybody. */
+extern int entries;/* Number of people. */
+extern int lflag;
+extern int oflag;
+extern int pplan;
+
+struct storage;
+
+voidenter_lastlog(PERSON *);
+PERSON *enter_person(struct passwd *);
+voidenter_where(struct utmp *, PERSON *);
+PERSON *find_person(char *);
+voidlflag_print(void);
+int match(struct passwd *, char *);
+voidnetfinger(char *);
+PERSON *palloc(void);
+char   *prphone(char *);
+voidsflag_print(void);
+char   *vs(struct storage **, char *);
+voidfree_storage(struct storage *);
+
Index: lprint.c
===
RCS file: /home/tleguern/proj/perso/cvs/src/usr.bin/finger/lprint.c,v
retrieving revision 1.10
diff -u -p -r1.10 lprint.c
--- lprint.c27 Oct 2009 23:59:38 -  1.10
+++ lprint.c21 Jul 2014 10:10:38 -
@@ -44,13 +44,17 @@
 #include paths.h
 #include vis.h
 #include finger.h
-#include extern.h

 #defineLINE_LEN80
 #defineTAB_LEN 8   /* 8 spaces between tabs */
 #define_PATH_PLAN  .plan
 #define_PATH_PROJECT   .project

+static int  demi_print(char *, int);
+static void lprint(PERSON *);
+static int  show_text(char *, char *, char *);
+static void vputc(int);
+
 void
 lflag_print(void)
 {
@@ -69,7 +73,7 @@ lflag_print(void)
}
 }

-void
+static void
 lprint(PERSON *pn)
 {
struct tm *delta;
@@ -220,7 +224,7 @@ lprint(PERSON *pn)
}
 }

-int
+static int
 demi_print(char *str, int oddfield)
 {
static int lenlast;
@@ -258,7 +262,7 @@ demi_print(char *str, int oddfield)
return (oddfield);
 }

-int
+static int
 show_text(char *directory, char *file_name, char *header)
 {
int ch, lastc;
@@ -277,7 +281,7 @@ show_text(char *directory, char *file_na
return (1);
 }

-void
+static void
 vputc(int ch)
 {
char visout[5], *s2;
Index: net.c
===
RCS file: /home/tleguern/proj/perso/cvs/src/usr.bin/finger/net.c,v
retrieving revision 1.12
diff -u -p -r1.12 net.c
--- net.c   27 Oct 2009 23:59:38 -  1.12
+++ net.c   21 Jul 2014 09:56:12 -
@@ -43,7 +43,6 @@
 #include unistd.h
 #include err.h
 #include finger.h
-#include extern.h

 void
 netfinger(name)
Index: sprint.c
===
RCS file: /home/tleguern/proj/perso/cvs/src/usr.bin/finger/sprint.c,v
retrieving revision 1.13
diff -u -p -r1.13 sprint.c
--- sprint.c27 Oct 2009 23:59:38 -  1.13
+++ sprint.c21 Jul 2014 10:11:51 -
@@ -40,7 +40,10 @@
 #include string.h
 #include err.h
 #include finger.h
-#include extern.h
+
+static int   psort(const void *, const void *);
+static PERSON  **sort(void);
+static void  stimeprint(WHERE *);

 void
 sflag_print(void)
@@ -130,7 +133,7 @@ office:
}
 }

-PERSON **
+static PERSON **
 sort(void)
 {
PERSON *pn, **lp;
@@ -144,13 +147,13 @@ sort(void)
return (list);
 }

-int
+static int
 psort(const void *p, const void *t)
 {
return (strcmp((*(PERSON **)p)-name, (*(PERSON **)t)-name));
 }

-void
+static void
 stimeprint(WHERE *w)
 {
struct tm *delta;
Index: util.c
===
RCS file: /home/tleguern/proj/perso/cvs/src/usr.bin/finger/util.c,v

/etc/rc nit

2014-07-21 Thread Alex Holst
Shouldn't /etc/rc check for executable bits in these two cases?

Index: etc/rc
===
RCS file: /var/cvsync/src/etc/rc,v
retrieving revision 1.437
diff -u -p -r1.437 rc
--- etc/rc  19 Jul 2014 21:27:16 -  1.437
+++ etc/rc  21 Jul 2014 15:59:29 -
@@ -322,7 +322,7 @@ rm -f /fastboot # XXX (root now writeab
 echo 'setting tty flags'
 ttyflags -a
 
-if [ -f /sbin/kbd -a -f /etc/kbdtype ]; then
+if [ -x /sbin/kbd -a -f /etc/kbdtype ]; then
kbd `cat /etc/kbdtype`
 fi
 
@@ -485,7 +485,7 @@ if [ X${accounting} = XYES ]; then
echo 'turning on accounting';   accton /var/account/acct
 fi
 
-if [ -f /sbin/ldconfig ]; then
+if [ -x /sbin/ldconfig ]; then
echo 'creating runtime link editor directory cache.'
if [ -d /usr/local/lib ]; then
shlib_dirs=/usr/local/lib $shlib_dirs



Re: res_random.c: 'static' is not at beginning of declaration

2014-07-21 Thread Theo de Raadt
revision 1.21
date: 2014/07/20 04:22:34;  author: guenther;  state: Exp;  lines: +2 -2;  
commitid: x7aBoxPF8nZvW5Z0;
From ISO/IEC 9899:1999 and 9899:201x,
6.11.5 - Storage-class specifiers:
The placement of a storage-class specifier other than at the
beginning of the declaration specifiers in a declaration is
an obsolescent feature.

Diff from Jean-Philippe Ouellet (jean-philippe (at) ouellet.biz)


This got fixed a few days ago.




LibreSSL 2.0.3 released

2014-07-21 Thread Bob Beck

We have released an update, LibreSSL 2.0.3 - which should
be arriving in the LibreSSL directory of an OpenBSD mirror near
you very soon. 

This release includes a number of portability fixes based on the
the feedback we have received from the community. It also includes
some improvements to the fork detection support. 

As noted before, we welcome feedback from the broader community.

Enjoy,  

-Bob
  



PATCH: reallocarray in a few places in sys/

2014-07-21 Thread Doug Hogan
Use reallocarray() in a few places in sys.


Index: sys/arch/hppa/stand/mkboot/mkboot.c
===
RCS file: /cvs/src/sys/arch/hppa/stand/mkboot/mkboot.c,v
retrieving revision 1.18
diff -u -p -d -r1.18 mkboot.c
--- sys/arch/hppa/stand/mkboot/mkboot.c 22 Jan 2014 09:18:04 -  1.18
+++ sys/arch/hppa/stand/mkboot/mkboot.c 22 Jul 2014 01:11:23 -
@@ -204,10 +204,11 @@ putfile(char *from_file, int to)
if (n != sizeof (elf_header))
err(1, %s: reading ELF header, from_file);
header_count = ntohs(elf_header.e_phnum);
-   memory_needed = header_count * sizeof (*elf_segments);
-   elf_segments = malloc(memory_needed);
+   elf_segments = reallocarray(NULL, header_count,
+   sizeof(*elf_segments));
if (elf_segments == NULL)
err(1, malloc);
+   memory_needed = header_count * sizeof(*elf_segments);
(void) lseek(from, ntohl(elf_header.e_phoff), SEEK_SET);
n = read(from, elf_segments, memory_needed);
if (n != memory_needed)
Index: sys/arch/hppa64/stand/mkboot/mkboot.c
===
RCS file: /cvs/src/sys/arch/hppa64/stand/mkboot/mkboot.c,v
retrieving revision 1.4
diff -u -p -d -r1.4 mkboot.c
--- sys/arch/hppa64/stand/mkboot/mkboot.c   22 Jan 2014 09:26:55 -  
1.4
+++ sys/arch/hppa64/stand/mkboot/mkboot.c   22 Jul 2014 01:11:24 -
@@ -204,10 +204,11 @@ putfile(char *from_file, int to)
if (n != sizeof (elf_header))
err(1, %s: reading ELF header, from_file);
header_count = betoh32(elf_header.e_phnum);
-   memory_needed = header_count * sizeof (*elf_segments);
-   elf_segments = malloc(memory_needed);
+   elf_segments = reallocarray(NULL, header_count,
+   sizeof(*elf_segments));
if (elf_segments == NULL)
err(1, malloc);
+   memory_needed = header_count * sizeof(*elf_segments);
(void) lseek(from, betoh32(elf_header.e_phoff), SEEK_SET);
n = read(from, elf_segments, memory_needed);
if (n != memory_needed)
Index: sys/dev/microcode/bwi/extract/extract.c
===
RCS file: /cvs/src/sys/dev/microcode/bwi/extract/extract.c,v
retrieving revision 1.3
diff -u -p -d -r1.3 extract.c
--- sys/dev/microcode/bwi/extract/extract.c 12 Jul 2014 19:01:49 -  
1.3
+++ sys/dev/microcode/bwi/extract/extract.c 22 Jul 2014 01:14:43 -
@@ -53,7 +53,7 @@ main(int argc, char *argv[])
nfiles = ntohl(nfiles);
 
/* allocate space for header struct */
-   if ((h = malloc(nfiles * sizeof(*h))) == NULL)
+   if ((h = reallocarray(NULL, nfiles, sizeof(*h))) == NULL)
err(1, malloc);
for (i = 0; i  nfiles; i++) {
if ((h[i] = malloc(sizeof(struct header))) == NULL)



PATCH: Remove useless if !NULL check before BIO_free() in LibreSSL

2014-07-21 Thread Doug Hogan
BIO_free() returns immediately when the sole input is NULL.


Index: lib/libssl/src/apps/apps.c
===
RCS file: /cvs/src/lib/libssl/src/apps/apps.c,v
retrieving revision 1.68
diff -u -p -d -r1.68 apps.c
--- lib/libssl/src/apps/apps.c  19 Jul 2014 03:40:26 -  1.68
+++ lib/libssl/src/apps/apps.c  22 Jul 2014 05:14:46 -
@@ -669,8 +669,7 @@ end:
BIO_printf(err, unable to load certificate\n);
ERR_print_errors(err);
}
-   if (cert != NULL)
-   BIO_free(cert);
+   BIO_free(cert);
return (x);
 }
 
@@ -745,8 +744,7 @@ load_key(BIO *err, const char *file, int
goto end;
}
 end:
-   if (key != NULL)
-   BIO_free(key);
+   BIO_free(key);
if (pkey == NULL) {
BIO_printf(err, unable to load %s\n, key_descrip);
ERR_print_errors(err);
@@ -833,8 +831,7 @@ load_pubkey(BIO *err, const char *file, 
}
 
 end:
-   if (key != NULL)
-   BIO_free(key);
+   BIO_free(key);
if (pkey == NULL)
BIO_printf(err, unable to load %s\n, key_descrip);
return (pkey);
Index: lib/libssl/src/apps/dh.c
===
RCS file: /cvs/src/lib/libssl/src/apps/dh.c,v
retrieving revision 1.25
diff -u -p -d -r1.25 dh.c
--- lib/libssl/src/apps/dh.c14 Jul 2014 00:35:10 -  1.25
+++ lib/libssl/src/apps/dh.c22 Jul 2014 05:14:46 -
@@ -297,8 +297,7 @@ bad:
ret = 0;
 
 end:
-   if (in != NULL)
-   BIO_free(in);
+   BIO_free(in);
if (out != NULL)
BIO_free_all(out);
if (dh != NULL)
Index: lib/libssl/src/apps/dhparam.c
===
RCS file: /cvs/src/lib/libssl/src/apps/dhparam.c,v
retrieving revision 1.33
diff -u -p -d -r1.33 dhparam.c
--- lib/libssl/src/apps/dhparam.c   14 Jul 2014 00:35:10 -  1.33
+++ lib/libssl/src/apps/dhparam.c   22 Jul 2014 05:14:47 -
@@ -441,8 +441,7 @@ bad:
ret = 0;
 
 end:
-   if (in != NULL)
-   BIO_free(in);
+   BIO_free(in);
if (out != NULL)
BIO_free_all(out);
if (dh != NULL)
Index: lib/libssl/src/apps/dsa.c
===
RCS file: /cvs/src/lib/libssl/src/apps/dsa.c,v
retrieving revision 1.28
diff -u -p -d -r1.28 dsa.c
--- lib/libssl/src/apps/dsa.c   14 Jul 2014 00:35:10 -  1.28
+++ lib/libssl/src/apps/dsa.c   22 Jul 2014 05:14:55 -
@@ -320,8 +320,7 @@ bad:
} else
ret = 0;
 end:
-   if (in != NULL)
-   BIO_free(in);
+   BIO_free(in);
if (out != NULL)
BIO_free_all(out);
if (dsa != NULL)
Index: lib/libssl/src/apps/dsaparam.c
===
RCS file: /cvs/src/lib/libssl/src/apps/dsaparam.c,v
retrieving revision 1.34
diff -u -p -d -r1.34 dsaparam.c
--- lib/libssl/src/apps/dsaparam.c  14 Jul 2014 00:35:10 -  1.34
+++ lib/libssl/src/apps/dsaparam.c  22 Jul 2014 05:15:02 -
@@ -382,8 +382,7 @@ bad:
ret = 0;
 
 end:
-   if (in != NULL)
-   BIO_free(in);
+   BIO_free(in);
if (out != NULL)
BIO_free_all(out);
if (dsa != NULL)
Index: lib/libssl/src/apps/ec.c
===
RCS file: /cvs/src/lib/libssl/src/apps/ec.c,v
retrieving revision 1.16
diff -u -p -d -r1.16 ec.c
--- lib/libssl/src/apps/ec.c14 Jul 2014 00:35:10 -  1.16
+++ lib/libssl/src/apps/ec.c22 Jul 2014 05:15:02 -
@@ -328,8 +328,7 @@ bad:
} else
ret = 0;
 end:
-   if (in)
-   BIO_free(in);
+   BIO_free(in);
if (out)
BIO_free_all(out);
if (eckey)
Index: lib/libssl/src/apps/ecparam.c
===
RCS file: /cvs/src/lib/libssl/src/apps/ecparam.c,v
retrieving revision 1.23
diff -u -p -d -r1.23 ecparam.c
--- lib/libssl/src/apps/ecparam.c   14 Jul 2014 00:35:10 -  1.23
+++ lib/libssl/src/apps/ecparam.c   22 Jul 2014 05:15:03 -
@@ -578,8 +578,7 @@ end:
if (ec_cofactor)
BN_free(ec_cofactor);
free(buffer);
-   if (in != NULL)
-   BIO_free(in);
+   BIO_free(in);
if (out != NULL)
BIO_free_all(out);
if (group != NULL)
Index: lib/libssl/src/apps/enc.c
===
RCS file: /cvs/src/lib/libssl/src/apps/enc.c,v
retrieving revision 1.38
diff -u -p -d -r1.38 enc.c
--- lib/libssl/src/apps/enc.c   14 Jul 2014 00:35:10 -  1.38
+++ lib/libssl/src/apps/enc.c   22 Jul 2014 05:15:04 -
@@ -600,17 +600,13 @@ end: