Why is sprintf ifdef-ed out of <stdio.h>?

trinkle at cs.purdue.edu trinkle at cs.purdue.edu
Sat Aug 12 00:06:35 AEST 1989


bob at omni.com (Bob Weissman) asks why there is an `#ifdef vax' around the
`char *sprintf()' declaration in stdio.h.

and chris at mimsy.umd.edu (Chris Torek) replies:
The reason is that sprintf() is supposed to return an int value, namely
the number of characters printed, but it was `too painful' to fix this for
4.2 and 4.3 BSD, so it was left *wrong* in the BSD VAX systems and made
correct in SunOS.

Actually, it depends on what was compiled into your C library.  There are
two source files for the SunOS 4.0 sprintf() routine.  One returns the
char * consistent with 4.2 BSD and the other returns an int (the character
count).  The bad thing is that Sun's /usr/lib/lint/llib-lc says that
sprintf() returns a char *.  Clearly, this is not always true and it does
not agree with /usr/include/stdio.h.

But then who really uses lint anyway -- clearly not Sun.  When checking
rpc.yppasswdd.c (we added some features and fixed a security whole) I saw
things like calls to socket() and bind() with too many arguments,
redefining a standard library routine (rresvport()), and much more.  This
is just one example out of hundreds, but something that is clearly all Sun
(not borrowed from BSD).  These are the poeple that are claiming to have
an "almost" C2 secure system?!

Script started on Fri Aug 11 08:55:04 1989
bors 6: lint /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig
lint: Warning: File with unknown suffix (/usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig) passed to lint1
/usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(149): warning: fp unused in function changepasswd
/usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(144): warning: argument rqstp unused in function changepasswd
getpwnam multiply declared      /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(371)  ::  llib-lc(339)
rresvport: variable # of args.  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(333)  ::  llib-lc(432)
rresvport multiply declared     /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(333)  ::  llib-lc(432)
pmap_unset, arg. 1 used inconsistently  llib-lc(622)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(99)
pmap_unset, arg. 2 used inconsistently  llib-lc(622)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(99)
svc_register, arg. 2 used inconsistently        llib-lc(627)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(101)
svc_register, arg. 3 used inconsistently        llib-lc(627)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(101)
svc_register, arg. 4 used inconsistently        llib-lc(627)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(101)
svc_sendreply, arg. 3 used inconsistently       llib-lc(629)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(133)
bzero, arg. 1 used inconsistently       llib-lc(227)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(163)
wait3, arg. 3 used inconsistently       llib-lc(196)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(171)
strcmp, arg. 1 used inconsistently      llib-lc(471)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(196)
crypt value used inconsistently llib-lc(233)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(196)
strcmp, arg. 1 used inconsistently      llib-lc(471)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(216)
crypt value used inconsistently llib-lc(233)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(216)
svc_sendreply, arg. 3 used inconsistently       llib-lc(629)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(328)
socket: variable # of args.     llib-lc(178)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(339)
bind: variable # of args.       llib-lc(55)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(344)
bind, arg. 2 used inconsistently        llib-lc(55)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(344)
crypt value declared inconsistently     llib-lc(233)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(216)
strcpy value declared inconsistently    llib-lc(472)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(310)
strcat value declared inconsistently    llib-lc(469)  ::  /usr/src/sun4.0/usr.etc/rpc.yppasswdd.c.orig(313)
fprintf returns value which is always ignored
pmap_unset returns value which is always ignored
close returns value which is always ignored
ioctl returns value which is always ignored
signal returns value which is sometimes ignored
fclose returns value which is always ignored
unlink returns value which is always ignored
strcpy returns value which is always ignored
strcat returns value which is always ignored
system returns value which is always ignored
bors 7: 
script done on Fri Aug 11 08:56:57 1989



More information about the Comp.sys.sun mailing list