changeset 4102:10e7c823462d

Get rid of strcpy() completely.
author Jonathan Schleifer <js-audacious@webkeks.org>
date Fri, 21 Dec 2007 18:39:46 +0100
parents 97efe5d31594
children 7b9d5718a6dc
files src/audacious/formatter.c src/audacious/intl/localcharset.c src/audacious/intl/log.c src/audacious/intl/os2compat.c src/audacious/intl/relocatable.c src/audacious/tuple_compiler.c src/audacious/ui_equalizer.c src/libid3tag/field.c
diffstat 8 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/formatter.c	Wed Dec 19 00:57:45 2007 -0600
+++ b/src/audacious/formatter.c	Fri Dec 21 18:39:46 2007 +0100
@@ -126,7 +126,7 @@
     for (p = format, q = buffer; *p; p++)
         if (*p == '%') {
             if (formatter->values[(int) *++p]) {
-                strcpy(q, formatter->values[(int) *p]);
+                strncpy(q, formatter->values[(int) *p], len - 1);
                 q += strlen(q);
             }
             else {
--- a/src/audacious/intl/localcharset.c	Wed Dec 19 00:57:45 2007 -0600
+++ b/src/audacious/intl/localcharset.c	Fri Dec 21 18:39:46 2007 +0100
@@ -186,8 +186,8 @@
 		  res_size = 0;
 		  break;
 		}
-	      strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
-	      strcpy (res_ptr + res_size - (l2 + 1), buf2);
+	      strncpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1, res_size - (l2 + 1));
+	      strncpy (res_ptr + res_size - (l2 + 1), buf2, res_size - (l1 + 1));
 	    }
 	  fclose (fp);
 	  if (res_size == 0)
--- a/src/audacious/intl/log.c	Wed Dec 19 00:57:45 2007 -0600
+++ b/src/audacious/intl/log.c	Fri Dec 21 18:39:46 2007 +0100
@@ -81,7 +81,7 @@
       last_logfilename = (char *) malloc (strlen (logfilename) + 1);
       if (last_logfilename == NULL)
 	return;
-      strcpy (last_logfilename, logfilename);
+      strncpy (last_logfilename, logfilename, strlen(logfilename) + 1);
       last_logfile = fopen (logfilename, "a");
       if (last_logfile == NULL)
 	return;
--- a/src/audacious/intl/os2compat.c	Wed Dec 19 00:57:45 2007 -0600
+++ b/src/audacious/intl/os2compat.c	Fri Dec 21 18:39:46 2007 +0100
@@ -94,5 +94,5 @@
     }
 
   if (strlen (_nlos2_localedir) <= MAXPATHLEN)
-    strcpy (libintl_nl_default_dirname, _nlos2_localedir);
+    strncpy (libintl_nl_default_dirname, _nlos2_localedir, MAXPATHLEN + 1);
 }
--- a/src/audacious/intl/relocatable.c	Wed Dec 19 00:57:45 2007 -0600
+++ b/src/audacious/intl/relocatable.c	Fri Dec 21 18:39:46 2007 +0100
@@ -427,7 +427,7 @@
 #endif
 	    {
 	      memcpy (result, curr_prefix, curr_prefix_len);
-	      strcpy (result + curr_prefix_len, pathname_tail);
+	      strncpy (result + curr_prefix_len, pathname_tail, strlen(pathname_tail) + 1);
 	      return result;
 	    }
 	}
--- a/src/audacious/tuple_compiler.c	Wed Dec 19 00:57:45 2007 -0600
+++ b/src/audacious/tuple_compiler.c	Fri Dec 21 18:39:46 2007 +0100
@@ -805,7 +805,7 @@
         *resmax = *reslen + MIN_ALLOC_BUF;
         *res = g_malloc(*resmax);
         
-        strcpy(*res, str);
+        strncpy(*res, str, *resmax);
       }
     }
     
--- a/src/audacious/ui_equalizer.c	Wed Dec 19 00:57:45 2007 -0600
+++ b/src/audacious/ui_equalizer.c	Fri Dec 21 18:39:46 2007 +0100
@@ -1094,7 +1094,7 @@
     vfs_fwrite("Winamp EQ library file v1.1\x1a!--", 1, 31, file);
 
     memset(name, 0, 257);
-    strcpy(name, "Entry1");
+    strncpy(name, "Entry1", 257);
     vfs_fwrite(name, 1, 257, file);
 
     for (i = 0; i < 10; i++)
--- a/src/libid3tag/field.c	Wed Dec 19 00:57:45 2007 -0600
+++ b/src/libid3tag/field.c	Fri Dec 21 18:39:46 2007 +0100
@@ -78,11 +78,11 @@
     break;
 
   case ID3_FIELD_TYPE_LANGUAGE:
-    strcpy(field->immediate.value, "XXX");
+    strncpy(field->immediate.value, "XXX", sizeof(field->immediate.value));
     break;
 
   case ID3_FIELD_TYPE_FRAMEID:
-    strcpy(field->immediate.value, "XXXX");
+    strncpy(field->immediate.value, "XXXX", sizeof(field->immediate.value));
     break;
 
   case ID3_FIELD_TYPE_DATE:
@@ -671,7 +671,7 @@
     if (strlen(language) != 3)
       return -1;
 
-    strcpy(field->immediate.value, language);
+    strncpy(field->immediate.value, language, sizeof(field->immediate.value));
   }
 
   return 0;