examples: Use snprintf() instead of sprintf() in dpfp and dpfp_threaded
authorPeter Stuge <peter@stuge.se>
Sat, 7 Apr 2012 03:20:36 +0000 (05:20 +0200)
committerPete Batard <pete@akeo.ie>
Mon, 9 Apr 2012 21:30:25 +0000 (22:30 +0100)
The OpenBSD C compiler generates a warning for every use of sprintf()
and for a good reason. Reported in http://marc.info/?m=133376187514495

Reported-by: Xiaofan Chen <xiaofanc@gmail.com>
examples/dpfp.c
examples/dpfp_threaded.c

index 7652407..55daff8 100644 (file)
@@ -226,7 +226,7 @@ static int save_to_file(unsigned char *data)
        FILE *fd;
        char filename[64];
 
-       sprintf(filename, "finger%d.pgm", img_idx++);
+       snprintf(filename, sizeof(filename), "finger%d.pgm", img_idx++);
        fd = fopen(filename, "w");
        if (!fd)
                return -1;
index a46d885..a0557c2 100644 (file)
@@ -255,7 +255,7 @@ static int save_to_file(unsigned char *data)
        FILE *fd;
        char filename[64];
 
-       sprintf(filename, "finger%d.pgm", img_idx++);
+       snprintf(filename, sizeof(filename), "finger%d.pgm", img_idx++);
        fd = fopen(filename, "w");
        if (!fd)
                return -1;