From 5d8aa4c7a50ad2bf115c1d6bcfbc5d698b8a705b Mon Sep 17 00:00:00 2001 From: christos Date: Thu, 31 May 2007 21:51:48 +0000 Subject: [PATCH] ssp is now part of libc. --- regress/lib/libc/Makefile | 6 +++--- regress/lib/libc/ssp/Makefile | 5 +++++ regress/lib/libc/ssp/Makefile.inc | 16 +++++++++++++++ regress/lib/libc/ssp/fgets/Makefile | 14 +++++++++++++ regress/lib/libc/ssp/fgets/fgets.c | 12 +++++++++++ regress/lib/libc/ssp/getcwd/Makefile | 14 +++++++++++++ regress/lib/libc/ssp/getcwd/getcwd.c | 14 +++++++++++++ regress/lib/libc/ssp/gets/Makefile | 14 +++++++++++++ regress/lib/libc/ssp/gets/gets.c | 10 +++++++++ regress/lib/libc/ssp/memcpy/Makefile | 14 +++++++++++++ regress/lib/libc/ssp/memcpy/memcpy.c | 14 +++++++++++++ regress/lib/libc/ssp/memmove/Makefile | 14 +++++++++++++ regress/lib/libc/ssp/memmove/memmove.c | 14 +++++++++++++ regress/lib/libc/ssp/memset/Makefile | 14 +++++++++++++ regress/lib/libc/ssp/memset/memset.c | 12 +++++++++++ regress/lib/libc/ssp/raw/Makefile | 14 +++++++++++++ regress/lib/libc/ssp/raw/raw.c | 22 ++++++++++++++++++++ regress/lib/libc/ssp/read/Makefile | 14 +++++++++++++ regress/lib/libc/ssp/read/read.c | 14 +++++++++++++ regress/lib/libc/ssp/readlink/Makefile | 14 +++++++++++++ regress/lib/libc/ssp/readlink/readlink.c | 14 +++++++++++++ regress/lib/libc/ssp/snprintf/Makefile | 14 +++++++++++++ regress/lib/libc/ssp/snprintf/snprintf.c | 12 +++++++++++ regress/lib/libc/ssp/sprintf/Makefile | 14 +++++++++++++ regress/lib/libc/ssp/sprintf/sprintf.c | 10 +++++++++ regress/lib/libc/ssp/strcat/Makefile | 14 +++++++++++++ regress/lib/libc/ssp/strcat/strcat.c | 13 ++++++++++++ regress/lib/libc/ssp/strcpy/Makefile | 14 +++++++++++++ regress/lib/libc/ssp/strcpy/strcpy.c | 12 +++++++++++ regress/lib/libc/ssp/strncat/Makefile | 14 +++++++++++++ regress/lib/libc/ssp/strncat/strncat.c | 15 ++++++++++++++ regress/lib/libc/ssp/strncpy/Makefile | 14 +++++++++++++ regress/lib/libc/ssp/strncpy/strncpy.c | 14 +++++++++++++ regress/lib/libc/ssp/vsnprintf/Makefile | 14 +++++++++++++ regress/lib/libc/ssp/vsnprintf/vsnprintf.c | 24 ++++++++++++++++++++++ regress/lib/libc/ssp/vsprintf/Makefile | 14 +++++++++++++ regress/lib/libc/ssp/vsprintf/vsprintf.c | 22 ++++++++++++++++++++ 37 files changed, 510 insertions(+), 3 deletions(-) create mode 100644 regress/lib/libc/ssp/Makefile create mode 100644 regress/lib/libc/ssp/Makefile.inc create mode 100644 regress/lib/libc/ssp/fgets/Makefile create mode 100644 regress/lib/libc/ssp/fgets/fgets.c create mode 100644 regress/lib/libc/ssp/getcwd/Makefile create mode 100644 regress/lib/libc/ssp/getcwd/getcwd.c create mode 100644 regress/lib/libc/ssp/gets/Makefile create mode 100644 regress/lib/libc/ssp/gets/gets.c create mode 100644 regress/lib/libc/ssp/memcpy/Makefile create mode 100644 regress/lib/libc/ssp/memcpy/memcpy.c create mode 100644 regress/lib/libc/ssp/memmove/Makefile create mode 100644 regress/lib/libc/ssp/memmove/memmove.c create mode 100644 regress/lib/libc/ssp/memset/Makefile create mode 100644 regress/lib/libc/ssp/memset/memset.c create mode 100644 regress/lib/libc/ssp/raw/Makefile create mode 100644 regress/lib/libc/ssp/raw/raw.c create mode 100644 regress/lib/libc/ssp/read/Makefile create mode 100644 regress/lib/libc/ssp/read/read.c create mode 100644 regress/lib/libc/ssp/readlink/Makefile create mode 100644 regress/lib/libc/ssp/readlink/readlink.c create mode 100644 regress/lib/libc/ssp/snprintf/Makefile create mode 100644 regress/lib/libc/ssp/snprintf/snprintf.c create mode 100644 regress/lib/libc/ssp/sprintf/Makefile create mode 100644 regress/lib/libc/ssp/sprintf/sprintf.c create mode 100644 regress/lib/libc/ssp/strcat/Makefile create mode 100644 regress/lib/libc/ssp/strcat/strcat.c create mode 100644 regress/lib/libc/ssp/strcpy/Makefile create mode 100644 regress/lib/libc/ssp/strcpy/strcpy.c create mode 100644 regress/lib/libc/ssp/strncat/Makefile create mode 100644 regress/lib/libc/ssp/strncat/strncat.c create mode 100644 regress/lib/libc/ssp/strncpy/Makefile create mode 100644 regress/lib/libc/ssp/strncpy/strncpy.c create mode 100644 regress/lib/libc/ssp/vsnprintf/Makefile create mode 100644 regress/lib/libc/ssp/vsnprintf/vsnprintf.c create mode 100644 regress/lib/libc/ssp/vsprintf/Makefile create mode 100644 regress/lib/libc/ssp/vsprintf/vsprintf.c diff --git a/regress/lib/libc/Makefile b/regress/lib/libc/Makefile index 25fd09b30826..ee71ac030861 100644 --- a/regress/lib/libc/Makefile +++ b/regress/lib/libc/Makefile @@ -1,9 +1,9 @@ -# $NetBSD: Makefile,v 1.52 2006/07/27 22:10:32 christos Exp $ +# $NetBSD: Makefile,v 1.53 2007/05/31 21:51:48 christos Exp $ SUBDIR+= _setjmp atexit basename citrus clone context convfp db dirname \ div divrem gen getaddrinfo hsearch int_fmtio locale md5sha \ - nsdispatch popen pty randomid regex rpc servent setjmp sigsetjmp stdio \ - stdlib string strptime sys time + nsdispatch popen pty randomid regex rpc servent setjmp sigsetjmp \ + ssp stdio stdlib string strptime sys time .include diff --git a/regress/lib/libc/ssp/Makefile b/regress/lib/libc/ssp/Makefile new file mode 100644 index 000000000000..c37316534729 --- /dev/null +++ b/regress/lib/libc/ssp/Makefile @@ -0,0 +1,5 @@ +# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:48 christos Exp $ +SUBDIR= fgets gets getcwd memcpy memmove memset raw read readlink \ + snprintf sprintf strcat strcpy strncat strncpy vsnprintf vsprintf + +.include diff --git a/regress/lib/libc/ssp/Makefile.inc b/regress/lib/libc/ssp/Makefile.inc new file mode 100644 index 000000000000..40383d15c9aa --- /dev/null +++ b/regress/lib/libc/ssp/Makefile.inc @@ -0,0 +1,16 @@ +# $NetBSD: Makefile.inc,v 1.1 2007/05/31 21:51:49 christos Exp $ + +WARNS= 4 + +CPPFLAGS+=-D_FORTIFY_SOURCE=2 +CFLAGS+=-fstack-protector-all -Wstack-protector +LDFLAGS+=-fstack-protector-all -Wstack-protector + +# Bootstrap hack + +.ifmake !clean && !obj && !cleandir +.BEGIN: + ${AR} cr libssp_nonshared.a +.endif +CLEANFILES+= libssp_nonshared.a +LDFLAGS+=-L. diff --git a/regress/lib/libc/ssp/fgets/Makefile b/regress/lib/libc/ssp/fgets/Makefile new file mode 100644 index 000000000000..5eec38f088c8 --- /dev/null +++ b/regress/lib/libc/ssp/fgets/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:49 christos Exp $ + +NOMAN= #defined + +.include + +PROG= fgets +SRCS= fgets.c + +regress: ${PROG} + echo ok | ./${PROG} 10 + -(echo busted | ./${PROG} 11) + +.include diff --git a/regress/lib/libc/ssp/fgets/fgets.c b/regress/lib/libc/ssp/fgets/fgets.c new file mode 100644 index 000000000000..da1fc5675266 --- /dev/null +++ b/regress/lib/libc/ssp/fgets/fgets.c @@ -0,0 +1,12 @@ +#include +#include + +int +main(int argc, char *argv[]) +{ + char b[10]; + int len = atoi(argv[1]); + (void)fgets(b, len, stdin); + (void)printf("%s\n", b); + return 0; +} diff --git a/regress/lib/libc/ssp/getcwd/Makefile b/regress/lib/libc/ssp/getcwd/Makefile new file mode 100644 index 000000000000..24d8af8cab29 --- /dev/null +++ b/regress/lib/libc/ssp/getcwd/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:49 christos Exp $ + +NOMAN= #defined + +.include + +PROG= getcwd +SRCS= getcwd.c + +regress: ${PROG} + ./${PROG} 1024 + -./${PROG} 1025 + +.include diff --git a/regress/lib/libc/ssp/getcwd/getcwd.c b/regress/lib/libc/ssp/getcwd/getcwd.c new file mode 100644 index 000000000000..a59a8e116d68 --- /dev/null +++ b/regress/lib/libc/ssp/getcwd/getcwd.c @@ -0,0 +1,14 @@ +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + char b[MAXPATHLEN]; + size_t len = atoi(argv[1]); + (void)getcwd(b, len); + (void)printf("%s\n", b); + return 0; +} diff --git a/regress/lib/libc/ssp/gets/Makefile b/regress/lib/libc/ssp/gets/Makefile new file mode 100644 index 000000000000..754d3f7cd057 --- /dev/null +++ b/regress/lib/libc/ssp/gets/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:50 christos Exp $ + +NOMAN= #defined + +.include + +PROG= gets +SRCS= gets.c + +regress: ${PROG} + echo ok | ./${PROG} + -(echo 0123456789 | ./${PROG}) + +.include diff --git a/regress/lib/libc/ssp/gets/gets.c b/regress/lib/libc/ssp/gets/gets.c new file mode 100644 index 000000000000..0a608fde4b65 --- /dev/null +++ b/regress/lib/libc/ssp/gets/gets.c @@ -0,0 +1,10 @@ +#include + +int +main(int argc, char *argv[]) +{ + char b[10]; + (void)gets(b); + (void)printf("%s\n", b); + return 0; +} diff --git a/regress/lib/libc/ssp/memcpy/Makefile b/regress/lib/libc/ssp/memcpy/Makefile new file mode 100644 index 000000000000..086b1a41504f --- /dev/null +++ b/regress/lib/libc/ssp/memcpy/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:50 christos Exp $ + +NOMAN= #defined + +.include + +PROG= memcpy +SRCS= memcpy.c + +regress: ${PROG} + ./${PROG} 10 + -./${PROG} 11 + +.include diff --git a/regress/lib/libc/ssp/memcpy/memcpy.c b/regress/lib/libc/ssp/memcpy/memcpy.c new file mode 100644 index 000000000000..68d6c9fcf2b4 --- /dev/null +++ b/regress/lib/libc/ssp/memcpy/memcpy.c @@ -0,0 +1,14 @@ +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + char b[10]; + int len = atoi(argv[1]); + (void)memcpy(b, "1020202020202", len); + + (void)printf("%*.*s\n", len, len, b); + return 0; +} diff --git a/regress/lib/libc/ssp/memmove/Makefile b/regress/lib/libc/ssp/memmove/Makefile new file mode 100644 index 000000000000..a68f3e923e21 --- /dev/null +++ b/regress/lib/libc/ssp/memmove/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:50 christos Exp $ + +NOMAN= #defined + +.include + +PROG= memmove +SRCS= memmove.c + +regress: ${PROG} + ./${PROG} 10 + -./${PROG} 11 + +.include diff --git a/regress/lib/libc/ssp/memmove/memmove.c b/regress/lib/libc/ssp/memmove/memmove.c new file mode 100644 index 000000000000..c8a7eebbb00a --- /dev/null +++ b/regress/lib/libc/ssp/memmove/memmove.c @@ -0,0 +1,14 @@ +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + char b[10]; + int len = atoi(argv[1]); + (void)memmove(b, "1020202020202", len); + + (void)printf("%*.*s\n", len, len, b); + return 0; +} diff --git a/regress/lib/libc/ssp/memset/Makefile b/regress/lib/libc/ssp/memset/Makefile new file mode 100644 index 000000000000..b38a10c7929d --- /dev/null +++ b/regress/lib/libc/ssp/memset/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:51 christos Exp $ + +NOMAN= #defined + +.include + +PROG= memset +SRCS= memset.c + +regress: ${PROG} + ./${PROG} 10 + -./${PROG} 11 + +.include diff --git a/regress/lib/libc/ssp/memset/memset.c b/regress/lib/libc/ssp/memset/memset.c new file mode 100644 index 000000000000..c2a204a6bcef --- /dev/null +++ b/regress/lib/libc/ssp/memset/memset.c @@ -0,0 +1,12 @@ +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + char b[10]; + size_t len = atoi(argv[1]); + (void)memset(b, 0, len); + return 0; +} diff --git a/regress/lib/libc/ssp/raw/Makefile b/regress/lib/libc/ssp/raw/Makefile new file mode 100644 index 000000000000..333e71a965fa --- /dev/null +++ b/regress/lib/libc/ssp/raw/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:51 christos Exp $ + +NOMAN= #defined + +.include + +PROG= raw +SRCS= raw.c + +regress: ${PROG} + ./${PROG} 9 + -./${PROG} 10 + +.include diff --git a/regress/lib/libc/ssp/raw/raw.c b/regress/lib/libc/ssp/raw/raw.c new file mode 100644 index 000000000000..30c369449c29 --- /dev/null +++ b/regress/lib/libc/ssp/raw/raw.c @@ -0,0 +1,22 @@ +#include +#include +#include + +static void raw(char *, size_t); + +static void +raw(char *b, size_t len) { + b[len] = '\0'; +} + +int +main(int argc, char *argv[]) +{ + char b[10]; + size_t len = atoi(argv[1]); + + (void)strncpy(b, "0000000000", sizeof(b)); + raw(b, len); + (void)printf("%s\n", b); + return 0; +} diff --git a/regress/lib/libc/ssp/read/Makefile b/regress/lib/libc/ssp/read/Makefile new file mode 100644 index 000000000000..1ae757b1525d --- /dev/null +++ b/regress/lib/libc/ssp/read/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:51 christos Exp $ + +NOMAN= #defined + +.include + +PROG= read +SRCS= read.c + +regress: ${PROG} + echo foo | ./${PROG} 1024 + -(echo bar | ./${PROG} 1025) + +.include diff --git a/regress/lib/libc/ssp/read/read.c b/regress/lib/libc/ssp/read/read.c new file mode 100644 index 000000000000..77a301328577 --- /dev/null +++ b/regress/lib/libc/ssp/read/read.c @@ -0,0 +1,14 @@ +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + char b[MAXPATHLEN]; + size_t len = atoi(argv[1]); + (void)read(0, b, len); + (void)printf("%s\n", b); + return 0; +} diff --git a/regress/lib/libc/ssp/readlink/Makefile b/regress/lib/libc/ssp/readlink/Makefile new file mode 100644 index 000000000000..7c7ee7340f20 --- /dev/null +++ b/regress/lib/libc/ssp/readlink/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:52 christos Exp $ + +NOMAN= #defined + +.include + +PROG= readlink +SRCS= readlink.c + +regress: ${PROG} + ./${PROG} 1024 + -./${PROG} 1025 + +.include diff --git a/regress/lib/libc/ssp/readlink/readlink.c b/regress/lib/libc/ssp/readlink/readlink.c new file mode 100644 index 000000000000..c0ffbebf3282 --- /dev/null +++ b/regress/lib/libc/ssp/readlink/readlink.c @@ -0,0 +1,14 @@ +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + char b[MAXPATHLEN]; + size_t len = atoi(argv[1]); + (void)readlink("/", b, len); + (void)printf("%s\n", b); + return 0; +} diff --git a/regress/lib/libc/ssp/snprintf/Makefile b/regress/lib/libc/ssp/snprintf/Makefile new file mode 100644 index 000000000000..7543795b2e64 --- /dev/null +++ b/regress/lib/libc/ssp/snprintf/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:52 christos Exp $ + +NOMAN= #defined + +.include + +PROG= snprintf +SRCS= snprintf.c + +regress: ${PROG} + ./${PROG} 10 + -./${PROG} 11 + +.include diff --git a/regress/lib/libc/ssp/snprintf/snprintf.c b/regress/lib/libc/ssp/snprintf/snprintf.c new file mode 100644 index 000000000000..77bb03566dd1 --- /dev/null +++ b/regress/lib/libc/ssp/snprintf/snprintf.c @@ -0,0 +1,12 @@ +#include +#include + +int +main(int argc, char *argv[]) +{ + char b[10]; + size_t len = atoi(argv[1]); + (void)snprintf(b, len, "%s", "0123456789"); + (void)printf("%s\n", b); + return 0; +} diff --git a/regress/lib/libc/ssp/sprintf/Makefile b/regress/lib/libc/ssp/sprintf/Makefile new file mode 100644 index 000000000000..57ed4f1ad628 --- /dev/null +++ b/regress/lib/libc/ssp/sprintf/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:52 christos Exp $ + +NOMAN= #defined + +.include + +PROG= sprintf +SRCS= sprintf.c + +regress: ${PROG} + ./${PROG} ok + -./${PROG} 0123456789 + +.include diff --git a/regress/lib/libc/ssp/sprintf/sprintf.c b/regress/lib/libc/ssp/sprintf/sprintf.c new file mode 100644 index 000000000000..bc7cc1173c88 --- /dev/null +++ b/regress/lib/libc/ssp/sprintf/sprintf.c @@ -0,0 +1,10 @@ +#include + +int +main(int argc, char *argv[]) +{ + char b[10]; + (void)sprintf(b, "%s", argv[1]); + (void)printf("%s\n", b); + return 0; +} diff --git a/regress/lib/libc/ssp/strcat/Makefile b/regress/lib/libc/ssp/strcat/Makefile new file mode 100644 index 000000000000..f17155077368 --- /dev/null +++ b/regress/lib/libc/ssp/strcat/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:53 christos Exp $ + +NOMAN= #defined + +.include + +PROG= strcat +SRCS= strcat.c + +regress: ${PROG} + ./${PROG} 0123456 + -./${PROG} 012345678 + +.include diff --git a/regress/lib/libc/ssp/strcat/strcat.c b/regress/lib/libc/ssp/strcat/strcat.c new file mode 100644 index 000000000000..304ce58ecefe --- /dev/null +++ b/regress/lib/libc/ssp/strcat/strcat.c @@ -0,0 +1,13 @@ +#include +#include + +int +main(int argc, char *argv[]) +{ + char b[10]; + (void)strcpy(b, "1"); + (void)strcat(b, argv[1]); + + (void)printf("%s\n", b); + return 0; +} diff --git a/regress/lib/libc/ssp/strcpy/Makefile b/regress/lib/libc/ssp/strcpy/Makefile new file mode 100644 index 000000000000..60d3fb06ba84 --- /dev/null +++ b/regress/lib/libc/ssp/strcpy/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:53 christos Exp $ + +NOMAN= #defined + +.include + +PROG= strcpy +SRCS= strcpy.c + +regress: ${PROG} + ./${PROG} 0123456 + -./${PROG} 0123456789 + +.include diff --git a/regress/lib/libc/ssp/strcpy/strcpy.c b/regress/lib/libc/ssp/strcpy/strcpy.c new file mode 100644 index 000000000000..f4ac6cc3e35e --- /dev/null +++ b/regress/lib/libc/ssp/strcpy/strcpy.c @@ -0,0 +1,12 @@ +#include +#include + +int +main(int argc, char *argv[]) +{ + char b[10]; + (void)strcpy(b, argv[1]); + + (void)printf("%s\n", b); + return 0; +} diff --git a/regress/lib/libc/ssp/strncat/Makefile b/regress/lib/libc/ssp/strncat/Makefile new file mode 100644 index 000000000000..0a4de6a3b12e --- /dev/null +++ b/regress/lib/libc/ssp/strncat/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:54 christos Exp $ + +NOMAN= #defined + +.include + +PROG= strncat +SRCS= strncat.c + +regress: ${PROG} + ./${PROG} 8 + -./${PROG} 9 + +.include diff --git a/regress/lib/libc/ssp/strncat/strncat.c b/regress/lib/libc/ssp/strncat/strncat.c new file mode 100644 index 000000000000..b7f20e861c46 --- /dev/null +++ b/regress/lib/libc/ssp/strncat/strncat.c @@ -0,0 +1,15 @@ +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + char b[10]; + int len = atoi(argv[1]); + (void)strcpy(b, "1"); + (void)strncat(b, "1020202020202", len); + + (void)printf("%*.*s\n", len, len, b); + return 0; +} diff --git a/regress/lib/libc/ssp/strncpy/Makefile b/regress/lib/libc/ssp/strncpy/Makefile new file mode 100644 index 000000000000..dfaddccfcc9f --- /dev/null +++ b/regress/lib/libc/ssp/strncpy/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:54 christos Exp $ + +NOMAN= #defined + +.include + +PROG= strncpy +SRCS= strncpy.c + +regress: ${PROG} + ./${PROG} 10 + -./${PROG} 11 + +.include diff --git a/regress/lib/libc/ssp/strncpy/strncpy.c b/regress/lib/libc/ssp/strncpy/strncpy.c new file mode 100644 index 000000000000..dfc005ed18bc --- /dev/null +++ b/regress/lib/libc/ssp/strncpy/strncpy.c @@ -0,0 +1,14 @@ +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + char b[10]; + int len = atoi(argv[1]); + (void)strncpy(b, "1020202020202", len); + + (void)printf("%*.*s\n", len, len, b); + return 0; +} diff --git a/regress/lib/libc/ssp/vsnprintf/Makefile b/regress/lib/libc/ssp/vsnprintf/Makefile new file mode 100644 index 000000000000..0b5544d35b26 --- /dev/null +++ b/regress/lib/libc/ssp/vsnprintf/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:54 christos Exp $ + +NOMAN= #defined + +.include + +PROG= vsnprintf +SRCS= vsnprintf.c + +regress: ${PROG} + ./${PROG} 10 + -./${PROG} 11 + +.include diff --git a/regress/lib/libc/ssp/vsnprintf/vsnprintf.c b/regress/lib/libc/ssp/vsnprintf/vsnprintf.c new file mode 100644 index 000000000000..86fc66f4fd20 --- /dev/null +++ b/regress/lib/libc/ssp/vsnprintf/vsnprintf.c @@ -0,0 +1,24 @@ +#include +#include +#include + +static void wrap(char *str, size_t, const char *, ...); + +static void +wrap(char *str, size_t len, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + (void)vsnprintf(str, len, fmt, ap); + va_end(ap); +} + +int +main(int argc, char *argv[]) +{ + char b[10]; + size_t len = atoi(argv[1]); + wrap(b, len, "%s", "012345678910"); + (void)printf("%s\n", b); + return 0; +} diff --git a/regress/lib/libc/ssp/vsprintf/Makefile b/regress/lib/libc/ssp/vsprintf/Makefile new file mode 100644 index 000000000000..faf9e138f4c4 --- /dev/null +++ b/regress/lib/libc/ssp/vsprintf/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:55 christos Exp $ + +NOMAN= #defined + +.include + +PROG= vsprintf +SRCS= vsprintf.c + +regress: ${PROG} + ./${PROG} ok + -./${PROG} 0123456789 + +.include diff --git a/regress/lib/libc/ssp/vsprintf/vsprintf.c b/regress/lib/libc/ssp/vsprintf/vsprintf.c new file mode 100644 index 000000000000..f8076487fd3f --- /dev/null +++ b/regress/lib/libc/ssp/vsprintf/vsprintf.c @@ -0,0 +1,22 @@ +#include +#include + +static void wrap(char *str, const char *, ...); + +static void +wrap(char *str, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + (void)vsprintf(str, fmt, ap); + va_end(ap); +} + +int +main(int argc, char *argv[]) +{ + char b[10]; + wrap(b, "%s", argv[1]); + (void)printf("%s\n", b); + return 0; +}