Module Name:    src
Committed By:   christos
Date:           Tue Dec 28 16:18:46 UTC 2010

Modified Files:
        src/tests/lib/libc/ssp: h_vsnprintf.c h_vsprintf.c

Log Message:
allocate the buffer at the same function level as the compiler so that
the compiler knows to emit the right _chk call.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/ssp/h_vsnprintf.c \
    src/tests/lib/libc/ssp/h_vsprintf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libc/ssp/h_vsnprintf.c
diff -u src/tests/lib/libc/ssp/h_vsnprintf.c:1.1 src/tests/lib/libc/ssp/h_vsnprintf.c:1.2
--- src/tests/lib/libc/ssp/h_vsnprintf.c:1.1	Sun Dec 26 21:04:19 2010
+++ src/tests/lib/libc/ssp/h_vsnprintf.c	Tue Dec 28 11:18:46 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: h_vsnprintf.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+/* $NetBSD: h_vsnprintf.c,v 1.2 2010/12/28 16:18:46 christos Exp $ */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,29 +29,29 @@
 #include <sys/cdefs.h>
 __COPYRIGHT("@(#) Copyright (c) 2008\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: h_vsnprintf.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+__RCSID("$NetBSD: h_vsnprintf.c,v 1.2 2010/12/28 16:18:46 christos Exp $");
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
 
-static void wrap(char *str, size_t, const char *, ...);
+void wrap(size_t, const char *, ...);
 
-static void
-wrap(char *str, size_t len, const char *fmt, ...)
+void
+wrap(size_t len, const char *fmt, ...)
 {
+	char b[10];
 	va_list ap;
 	va_start(ap, fmt);
-	(void)vsnprintf(str, len, fmt, ap);
+	(void)vsnprintf(b, len, fmt, ap);
+	(void)printf("%s\n", b);
 	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);
+	wrap(len, "%s", "012345678901234567890");
 	return 0;
 }
Index: src/tests/lib/libc/ssp/h_vsprintf.c
diff -u src/tests/lib/libc/ssp/h_vsprintf.c:1.1 src/tests/lib/libc/ssp/h_vsprintf.c:1.2
--- src/tests/lib/libc/ssp/h_vsprintf.c:1.1	Sun Dec 26 21:04:19 2010
+++ src/tests/lib/libc/ssp/h_vsprintf.c	Tue Dec 28 11:18:46 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: h_vsprintf.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+/* $NetBSD: h_vsprintf.c,v 1.2 2010/12/28 16:18:46 christos Exp $ */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,27 +29,27 @@
 #include <sys/cdefs.h>
 __COPYRIGHT("@(#) Copyright (c) 2008\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: h_vsprintf.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+__RCSID("$NetBSD: h_vsprintf.c,v 1.2 2010/12/28 16:18:46 christos Exp $");
 
 #include <stdio.h>
 #include <stdarg.h>
 
-static void wrap(char *str, const char *, ...);
+static void wrap(const char *, ...);
 
 static void
-wrap(char *str, const char *fmt, ...)
+wrap(const char *fmt, ...)
 {
+	char b[10];
 	va_list ap;
 	va_start(ap, fmt);
-	(void)vsprintf(str, fmt, ap);
+	(void)vsprintf(b, fmt, ap);
+	(void)printf("%s\n", b);
 	va_end(ap);
 }
 
 int
 main(int argc, char *argv[])
 {
-	char b[10];
-	wrap(b, "%s", argv[1]);
-	(void)printf("%s\n", b);
+	wrap("%s", argv[1]);
 	return 0;
 }

Reply via email to