Potential crash due to missing declaration of strerror

Corinna Vinschen vinschen at redhat.com
Sat Dec 7 22:33:49 EST 2013


Hi,

I've just stumbled over this gcc warning while building OpenSSH:

  openbsd-compat/bsd-setres_id.c:41:3: warning: implicit declaration of function ‘strerror’ [-Wimplicit-function-declaration]
     error("setregid %u: %.100s", rgid, strerror(errno));
     ^
  openbsd-compat/bsd-setres_id.c:41:3: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat=]

This almost certainly results in a crash on systems with
sizeof(char*) > sizeof(int), like on practically all 64 bit systems.

This simple patch fixes it:

Index: openbsd-compat/bsd-setres_id.c
===================================================================
RCS file: /cvs/openssh/openbsd-compat/bsd-setres_id.c,v
retrieving revision 1.1
diff -u -p -r1.1 bsd-setres_id.c
--- openbsd-compat/bsd-setres_id.c	5 Nov 2012 06:04:37 -0000	1.1
+++ openbsd-compat/bsd-setres_id.c	7 Dec 2013 10:57:31 -0000
@@ -22,6 +22,7 @@
 
 #include <stdarg.h>
 #include <unistd.h>
+#include <string.h>
 
 #include "log.h"
 

Hope that helps,
Corinna
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20131207/75660104/attachment.bin>


More information about the openssh-unix-dev mailing list