ssp is now part of libc.

This commit is contained in:
christos 2007-05-31 21:51:48 +00:00
parent 201eeae43d
commit 5d8aa4c7a5
37 changed files with 510 additions and 3 deletions

View File

@ -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 <bsd.own.mk>

View File

@ -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 <bsd.subdir.mk>

View File

@ -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.

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:49 christos Exp $
NOMAN= #defined
.include <bsd.own.mk>
PROG= fgets
SRCS= fgets.c
regress: ${PROG}
echo ok | ./${PROG} 10
-(echo busted | ./${PROG} 11)
.include <bsd.prog.mk>

View File

@ -0,0 +1,12 @@
#include <stdio.h>
#include <stdlib.h>
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;
}

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:49 christos Exp $
NOMAN= #defined
.include <bsd.own.mk>
PROG= getcwd
SRCS= getcwd.c
regress: ${PROG}
./${PROG} 1024
-./${PROG} 1025
.include <bsd.prog.mk>

View File

@ -0,0 +1,14 @@
#include <sys/param.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
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;
}

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:50 christos Exp $
NOMAN= #defined
.include <bsd.own.mk>
PROG= gets
SRCS= gets.c
regress: ${PROG}
echo ok | ./${PROG}
-(echo 0123456789 | ./${PROG})
.include <bsd.prog.mk>

View File

@ -0,0 +1,10 @@
#include <stdio.h>
int
main(int argc, char *argv[])
{
char b[10];
(void)gets(b);
(void)printf("%s\n", b);
return 0;
}

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:50 christos Exp $
NOMAN= #defined
.include <bsd.own.mk>
PROG= memcpy
SRCS= memcpy.c
regress: ${PROG}
./${PROG} 10
-./${PROG} 11
.include <bsd.prog.mk>

View File

@ -0,0 +1,14 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
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;
}

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:50 christos Exp $
NOMAN= #defined
.include <bsd.own.mk>
PROG= memmove
SRCS= memmove.c
regress: ${PROG}
./${PROG} 10
-./${PROG} 11
.include <bsd.prog.mk>

View File

@ -0,0 +1,14 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
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;
}

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:51 christos Exp $
NOMAN= #defined
.include <bsd.own.mk>
PROG= memset
SRCS= memset.c
regress: ${PROG}
./${PROG} 10
-./${PROG} 11
.include <bsd.prog.mk>

View File

@ -0,0 +1,12 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int
main(int argc, char *argv[])
{
char b[10];
size_t len = atoi(argv[1]);
(void)memset(b, 0, len);
return 0;
}

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:51 christos Exp $
NOMAN= #defined
.include <bsd.own.mk>
PROG= raw
SRCS= raw.c
regress: ${PROG}
./${PROG} 9
-./${PROG} 10
.include <bsd.prog.mk>

View File

@ -0,0 +1,22 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
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;
}

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:51 christos Exp $
NOMAN= #defined
.include <bsd.own.mk>
PROG= read
SRCS= read.c
regress: ${PROG}
echo foo | ./${PROG} 1024
-(echo bar | ./${PROG} 1025)
.include <bsd.prog.mk>

View File

@ -0,0 +1,14 @@
#include <sys/param.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
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;
}

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:52 christos Exp $
NOMAN= #defined
.include <bsd.own.mk>
PROG= readlink
SRCS= readlink.c
regress: ${PROG}
./${PROG} 1024
-./${PROG} 1025
.include <bsd.prog.mk>

View File

@ -0,0 +1,14 @@
#include <sys/param.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
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;
}

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:52 christos Exp $
NOMAN= #defined
.include <bsd.own.mk>
PROG= snprintf
SRCS= snprintf.c
regress: ${PROG}
./${PROG} 10
-./${PROG} 11
.include <bsd.prog.mk>

View File

@ -0,0 +1,12 @@
#include <stdio.h>
#include <stdlib.h>
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;
}

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:52 christos Exp $
NOMAN= #defined
.include <bsd.own.mk>
PROG= sprintf
SRCS= sprintf.c
regress: ${PROG}
./${PROG} ok
-./${PROG} 0123456789
.include <bsd.prog.mk>

View File

@ -0,0 +1,10 @@
#include <stdio.h>
int
main(int argc, char *argv[])
{
char b[10];
(void)sprintf(b, "%s", argv[1]);
(void)printf("%s\n", b);
return 0;
}

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:53 christos Exp $
NOMAN= #defined
.include <bsd.own.mk>
PROG= strcat
SRCS= strcat.c
regress: ${PROG}
./${PROG} 0123456
-./${PROG} 012345678
.include <bsd.prog.mk>

View File

@ -0,0 +1,13 @@
#include <stdio.h>
#include <string.h>
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;
}

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:53 christos Exp $
NOMAN= #defined
.include <bsd.own.mk>
PROG= strcpy
SRCS= strcpy.c
regress: ${PROG}
./${PROG} 0123456
-./${PROG} 0123456789
.include <bsd.prog.mk>

View File

@ -0,0 +1,12 @@
#include <stdio.h>
#include <string.h>
int
main(int argc, char *argv[])
{
char b[10];
(void)strcpy(b, argv[1]);
(void)printf("%s\n", b);
return 0;
}

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:54 christos Exp $
NOMAN= #defined
.include <bsd.own.mk>
PROG= strncat
SRCS= strncat.c
regress: ${PROG}
./${PROG} 8
-./${PROG} 9
.include <bsd.prog.mk>

View File

@ -0,0 +1,15 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
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;
}

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:54 christos Exp $
NOMAN= #defined
.include <bsd.own.mk>
PROG= strncpy
SRCS= strncpy.c
regress: ${PROG}
./${PROG} 10
-./${PROG} 11
.include <bsd.prog.mk>

View File

@ -0,0 +1,14 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
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;
}

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:54 christos Exp $
NOMAN= #defined
.include <bsd.own.mk>
PROG= vsnprintf
SRCS= vsnprintf.c
regress: ${PROG}
./${PROG} 10
-./${PROG} 11
.include <bsd.prog.mk>

View File

@ -0,0 +1,24 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
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;
}

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2007/05/31 21:51:55 christos Exp $
NOMAN= #defined
.include <bsd.own.mk>
PROG= vsprintf
SRCS= vsprintf.c
regress: ${PROG}
./${PROG} ok
-./${PROG} 0123456789
.include <bsd.prog.mk>

View File

@ -0,0 +1,22 @@
#include <stdio.h>
#include <stdarg.h>
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;
}