1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

- Added the test program for the sprintf() buffer flush bug, courtesy of

Jens Langner.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14725 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2004-09-10 07:41:13 +00:00
parent 6214bc2067
commit 6a2db55fc2
3 changed files with 40 additions and 6 deletions

View File

@ -1,5 +1,5 @@
# #
# $Id: GNUmakefile.68k,v 1.1 2004-08-14 15:01:22 obarthel Exp $ # $Id: GNUmakefile.68k,v 1.2 2004-09-10 07:41:13 obarthel Exp $
# #
# :ts=8 # :ts=8
# #
@ -46,10 +46,10 @@ LIBS = -lm -lc -lgcc
############################################################################## ##############################################################################
all: test fgets_test iotest sscanf_test printf_test stack_size_test translate_test all: test fgets_test iotest sscanf_test printf_test sprintf_test stack_size_test translate_test
clean: clean:
$(DELETE) #?.o #?.map test fgets_test iotest sscanf_test printf_test stack_size_test translate_test $(DELETE) #?.o #?.map test fgets_test iotest sscanf_test printf_test sprintf_test stack_size_test translate_test
############################################################################## ##############################################################################
@ -73,6 +73,10 @@ printf_test : printf_test.o
@echo "Linking $@" @echo "Linking $@"
$(CC) $(CFLAGS) -o $@ printf_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map $(CC) $(CFLAGS) -o $@ printf_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
sprintf_test : sprintf_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ sprintf_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
stack_size_test : stack_size_test.o stack_size_test : stack_size_test.o
@echo "Linking $@" @echo "Linking $@"
$(CC) $(CFLAGS) -o $@ stack_size_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map $(CC) $(CFLAGS) -o $@ stack_size_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map

View File

@ -1,5 +1,5 @@
# #
# $Id: smakefile,v 1.1 2004-08-06 11:51:50 obarthel Exp $ # $Id: smakefile,v 1.2 2004-09-10 07:41:13 obarthel Exp $
# #
# :ts=8 # :ts=8
# #
@ -63,10 +63,10 @@ AFLAGS = \
############################################################################## ##############################################################################
all: setup test fgets_test iotest sscanf_test printf_test stack_size_test translate_test cleanup all: setup test fgets_test iotest sscanf_test printf_test sprintf_test stack_size_test translate_test cleanup
clean: clean:
-delete \#?.o \#?.map test fgets_test iotest sscanf_test printf_test stack_size_test translate_test -delete \#?.o \#?.map test fgets_test iotest sscanf_test printf_test sprintf_test stack_size_test translate_test
############################################################################## ##############################################################################
@ -105,6 +105,11 @@ printf_test: printf_test.o
@slink $(LIB)startup.o printf_test.o to $@ lib $(LIB)c.lib addsym \ @slink $(LIB)startup.o printf_test.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32 map $@.map,fhx fwidth 32 pwidth 32 swidth 32
sprintf_test: sprintf_test.o
@echo "Linking $@"
@slink $(LIB)startup.o sprintf_test.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32
stack_size_test: stack_size_test.o stack_size_test: stack_size_test.o
@echo "Linking $@" @echo "Linking $@"
@slink $(LIB)startup.o stack_size_test.o to $@ lib $(LIB)c.lib addsym \ @slink $(LIB)startup.o stack_size_test.o to $@ lib $(LIB)c.lib addsym \

View File

@ -0,0 +1,25 @@
#include <string.h>
#include <stdio.h>
static char buf[256];
void addsomething(void)
{
char *p = &buf[strlen(buf)];
sprintf(p, "yeah");
}
int main(void)
{
buf[0] = '\0';
addsomething();
printf("1: [%s]\n", buf);
sprintf(buf, "");
addsomething();
printf("2: [%s]\n", buf);
return (0);
}