[Kst] extragear/graphics/kst/src/datasources/frame

Barth Netterfield netterfield at astro.utoronto.ca
Wed Mar 28 20:39:17 CEST 2007


SVN commit 647569 by netterfield:

BUG: 142420
strcpy -> strncpy 



 M  +4 -3      creaddata.c  
 M  +3 -2      readdata.c  


--- trunk/extragear/graphics/kst/src/datasources/frame/creaddata.c #647568:647569
@@ -24,6 +24,7 @@
 #define MAX_LINE_LENGTH 120
 #define MAX_FIELDS_IN_CFORMAT 500
 #define MAX_LINCOM_ENTRIES 4
+#define MAX_FILENAMELEN 256
 
 #ifndef CALSPECS_DIR
 #define CALSPECS_DIR "/data/etc"
@@ -838,7 +839,7 @@
   int i_format, i_field, i_lincom;
   int s_per_frame;
   static int first_time=1;
-  char filename[100], tmpfilename[100];
+  char filename[MAX_FILENAMELEN], tmpfilename[MAX_FILENAMELEN];
   int i, n_read;
   void *tmpbuf;
   int *mp_cnt=NULL, *mp_data, cp_data;
@@ -852,7 +853,7 @@
     return(0);
   }
 
-  strcpy(filename, filename_in);
+  strncpy(filename, filename_in, MAX_FILENAMELEN-2);
 
   if (first_time) {
     *error_code = ReadCalFile();
@@ -900,7 +901,7 @@
     /* Find t0 from the file creation time */
     t0 = FindT0(filename_in,  cstruct[i_format].field[i_field].framerate);
     /* Find f0 from reading the first frame val */
-    strcpy(tmpfilename, filename);
+    strncpy(tmpfilename, filename, MAX_FILENAMELEN-2);
     tmpfilename[strlen(tmpfilename)-2] = '0';
     tmpfilename[strlen(tmpfilename)-1] = '0';
 
--- trunk/extragear/graphics/kst/src/datasources/frame/readdata.c #647568:647569
@@ -27,6 +27,7 @@
 #include "readdata.h"
 #define MAX_LINE_LENGTH 120
 #define MAX_FIELDS_IN_FORMAT 500
+#define MAX_FILENAMELEN 256
 
 #ifndef FILEFORMATS_DIR
 #define FILEFORMATS_DIR "/data/etc"
@@ -782,9 +783,9 @@
   char done='n';
   unsigned char *data_buffer;
   int fp;
-  char filename[100];
+  char filename[MAX_FILENAMELEN];
 
-  strcpy(filename, filename_in);
+  strncpy(filename, filename_in, MAX_FILENAMELEN-2);
 
   /****************************/
   /* Read the FileFormat file */


More information about the Kst mailing list