Browse Source

warn about unsafe APIs at link time. Conditional on libc/Makefile defining

APIWARN; disabled by default.  In use by many developers for quite some time,
now they have a common knob to enable/disable this
OPENBSD_3_4
deraadt 21 years ago
parent
commit
e84beffb5d
2 changed files with 14 additions and 8 deletions
  1. +7
    -4
      src/lib/libc/string/strcat.c
  2. +7
    -4
      src/lib/libc/string/strcpy.c

+ 7
- 4
src/lib/libc/string/strcat.c View File

@ -28,7 +28,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char *rcsid = "$OpenBSD: strcat.c,v 1.5 2003/06/02 20:18:38 millert Exp $";
static char *rcsid = "$OpenBSD: strcat.c,v 1.6 2003/07/24 01:15:42 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#ifndef _KERNEL
@ -37,10 +37,13 @@ static char *rcsid = "$OpenBSD: strcat.c,v 1.5 2003/06/02 20:18:38 millert Exp $
#include <lib/libkern/libkern.h>
#endif
#if defined(APIWARN)
__warn_references(strcat,
"warning: strcat() is almost always misused, please use strlcat()");
#endif
char *
strcat(s, append)
register char *s;
register const char *append;
strcat(char *s, const char *append)
{
char *save = s;


+ 7
- 4
src/lib/libc/string/strcpy.c View File

@ -28,7 +28,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char *rcsid = "$OpenBSD: strcpy.c,v 1.5 2003/06/02 20:18:38 millert Exp $";
static char *rcsid = "$OpenBSD: strcpy.c,v 1.6 2003/07/24 01:15:42 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#ifndef _KERNEL
@ -37,10 +37,13 @@ static char *rcsid = "$OpenBSD: strcpy.c,v 1.5 2003/06/02 20:18:38 millert Exp $
#include <lib/libkern/libkern.h>
#endif
#if defined(APIWARN)
__warn_references(strcpy,
"warning: strcpy() is almost always misused, please use strlcpy()");
#endif
char *
strcpy(to, from)
register char *to;
register const char *from;
strcpy(char *to, const char *from)
{
char *save = to;


Loading…
Cancel
Save