more sprintfs
authordiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 3 Jan 2012 05:30:13 +0000 (05:30 +0000)
committerdiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 3 Jan 2012 05:30:13 +0000 (05:30 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@66778 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/elm_win.c

index 8b9644b..354c7b6 100644 (file)
@@ -144,9 +144,10 @@ _shot_file_get(Elm_Win *win)
                   char *dotptr = strrchr(tmp, '.');
                   if (dotptr)
                     {
-                       repname = malloc(sizeof(char)*(strlen(tmp) + 16));
+                       size_t size = sizeof(char)*(strlen(tmp) + 16);
+                       repname = malloc(size);
                        strncpy(repname, tmp, dotptr - tmp);
-                       sprintf(repname + (dotptr - tmp), "%03i",
+                       snprintf(repname + (dotptr - tmp), size - (dotptr - tmp), "%03i",
                                win->shot.shot_counter + 1);
                        strcat(repname, dotptr);
                        free(tmp);
@@ -157,12 +158,10 @@ _shot_file_get(Elm_Win *win)
      }
    free(tmp);
    if (!win->shot.repeat_count) return strdup("out.png");
-   else
-     {
-        repname = malloc(sizeof(char) * 24);
-        sprintf(repname, "out%03i.png", win->shot.shot_counter + 1);
-        return repname;
-     }
+
+   repname = malloc(sizeof(char) * 24);
+   snprintf(repname, sizeof(char) * 24, "out%03i.png", win->shot.shot_counter + 1);
+   return repname;
 }
 
 static int