Index: apps/onplay.c
===================================================================
RCS file: /cvsroot/rockbox/apps/onplay.c,v
retrieving revision 1.94
diff -u -r1.94 onplay.c
--- apps/onplay.c	14 Dec 2006 22:43:16 -0000	1.94
+++ apps/onplay.c	21 Dec 2006 07:18:23 -0000
@@ -582,7 +582,7 @@
 static bool clipboard_clip(bool copy)
 {
     clipboard_selection[0] = 0;
-    strncpy(clipboard_selection, selected_file, MAX_PATH);
+    strncpy(clipboard_selection, selected_file, sizeof clipboard_selection);
     clipboard_selection_attr = selected_file_attr;
     clipboard_is_copy = copy;
 
@@ -785,13 +785,12 @@
 
     /* Get the name of the current directory */
     cwd = getcwd(NULL, 0);
-    snprintf(target, sizeof target, "%s", cwd[1] ? cwd : "");
 
     /* Figure out the name of the selection */
     nameptr = strrchr(clipboard_selection, '/');
 
-    /* Paste the name on to the current directory to give us our final target */
-    strcat(target, nameptr);
+    /* Final target is current directory plus name of selection  */
+    snprintf(target, sizeof target, "%s%s", cwd[1] ? cwd : "", nameptr);
 
     /* Check if we're going to overwrite */
     target_fd = open(target, O_RDONLY);
Index: uisimulator/common/io.c
===================================================================
RCS file: /cvsroot/rockbox/uisimulator/common/io.c,v
retrieving revision 1.34
diff -u -r1.34 io.c
--- uisimulator/common/io.c	10 Nov 2006 08:03:33 -0000	1.34
+++ uisimulator/common/io.c	21 Dec 2006 07:19:06 -0000
@@ -103,13 +103,13 @@
 
 MYDIR *sim_opendir(const char *name)
 {
-    char buffer[256]; /* sufficiently big */
+    char buffer[MAX_PATH]; /* sufficiently big */
     DIR *dir;
 
 #ifndef __PCTOOL__
     if(name[0] == '/') 
     {
-        sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);    
+        snprintf(buffer, sizeof buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
         dir=(DIR *)opendir(buffer);
     }
     else
@@ -141,9 +141,9 @@
 
     /* build file name */
 #ifdef __PCTOOL__
-    sprintf(buffer, "%s/%s", dir->name, x11->d_name);
+    snprintf(buffer, sizeof buffer, "%s/%s", dir->name, x11->d_name);
 #else
-    sprintf(buffer, SIMULATOR_ARCHOS_ROOT "%s/%s",
+    snprintf(buffer, sizeof buffer, SIMULATOR_ARCHOS_ROOT "%s/%s",
             dir->name, x11->d_name);
 #endif
     stat(buffer, &s); /* get info */
@@ -168,13 +168,13 @@
 
 int sim_open(const char *name, int o)
 {
-    char buffer[256]; /* sufficiently big */
+    char buffer[MAX_PATH]; /* sufficiently big */
     int opts = rockbox2sim(o);
 
 #ifndef __PCTOOL__
     if(name[0] == '/') 
     {
-        sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
+        snprintf(buffer, sizeof buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
 
         debugf("We open the real file '%s'\n", buffer);
         return open(buffer, opts, 0666);
@@ -194,11 +194,11 @@
     int opts = rockbox2sim(mode);
     
 #ifndef __PCTOOL__
-    char buffer[256]; /* sufficiently big */
+    char buffer[MAX_PATH]; /* sufficiently big */
     if(name[0] == '/') 
     {
-        sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
-        
+        snprintf(buffer, sizeof buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
+
         debugf("We create the real file '%s'\n", buffer);
         return open(buffer, opts | O_CREAT | O_TRUNC, 0666);
     }
@@ -220,10 +220,10 @@
     return mkdir(name, 0777);
 # endif
 #else
-    char buffer[256]; /* sufficiently big */
+    char buffer[MAX_PATH]; /* sufficiently big */
+
+    snprintf(buffer, sizeof buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
 
-    sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
-        
     debugf("We create the real directory '%s'\n", buffer);
 #ifdef WIN32
     /* since we build with -DNOCYGWIN we have the plain win32 version */
@@ -239,11 +239,11 @@
 #ifdef __PCTOOL__
     return rmdir(name);
 #else
-    char buffer[256]; /* sufficiently big */
+    char buffer[MAX_PATH]; /* sufficiently big */
     if(name[0] == '/') 
     {
-        sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
-        
+        snprintf(buffer, sizeof buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
+
         debugf("We remove the real directory '%s'\n", buffer);
         return rmdir(buffer);
     }
@@ -256,14 +256,14 @@
 #ifdef __PCTOOL__
     return remove(name);
 #else
-    char buffer[256]; /* sufficiently big */
+    char buffer[MAX_PATH]; /* sufficiently big */
 
 #ifdef HAVE_DIRCACHE
     dircache_remove(name);
 #endif
 
     if(name[0] == '/') {
-        sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
+        snprintf(buffer, sizeof buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
 
         debugf("We remove the real file '%s'\n", buffer);
         return remove(buffer);
@@ -277,16 +277,16 @@
 #ifdef __PCTOOL__
     return rename(oldpath, newpath);
 #else
-    char buffer1[256];
-    char buffer2[256];
+    char buffer1[MAX_PATH];
+    char buffer2[MAX_PATH];
 
 #ifdef HAVE_DIRCACHE
     dircache_rename(oldpath, newpath);
 #endif
 
     if(oldpath[0] == '/') {
-        sprintf(buffer1, "%s%s", SIMULATOR_ARCHOS_ROOT, oldpath);
-        sprintf(buffer2, "%s%s", SIMULATOR_ARCHOS_ROOT, newpath);
+        snprintf(buffer1, sizeof buffer1, "%s%s", SIMULATOR_ARCHOS_ROOT, oldpath);
+        snprintf(buffer2, sizeof buffer2, "%s%s", SIMULATOR_ARCHOS_ROOT, newpath);
 
         debugf("We rename the real file '%s' to '%s'\n", buffer1, buffer2);
         return rename(buffer1, buffer2);
@@ -377,7 +377,7 @@
     int copy_n;
     int codec_count;
 #ifdef WIN32
-    char buf[256];
+    char buf[MAX_PATH];
 #endif
 
     *pd = NULL;
@@ -388,7 +388,7 @@
        to find an unused filename */
     for (codec_count = 0; codec_count < 10; codec_count++)
     {
-        sprintf(path, TEMP_CODEC_FILE, codec_count);
+        snprintf(path, sizeof path, TEMP_CODEC_FILE, codec_count);
 
     #ifdef WIN32
         fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU);
@@ -450,13 +450,13 @@
 void *sim_plugin_load(char *plugin, void **pd)
 {
     void *hdr;
-    char path[256];
+    char path[MAX_PATH];
 #ifdef WIN32
-    char buf[256];
+    char buf[MAX_PATH];
 #endif
 
     snprintf(path, sizeof path, "archos%s", plugin);
-    
+
     *pd = NULL;
 
     *pd = dlopen(path, RTLD_NOW);
