Imported Upstream version 5.1.9 into tizen
[platform/upstream/giflib.git] / gifinto.c
similarity index 96%
rename from util/gifinto.c
rename to gifinto.c
index 306c489..cda67bc 100644 (file)
+++ b/gifinto.c
@@ -4,7 +4,6 @@ gifinto - save GIF on stdin to file if size over set threshold
 
 *****************************************************************************/
 
-#include <unistd.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -14,6 +13,8 @@ gifinto - save GIF on stdin to file if size over set threshold
 
 #ifdef _WIN32
 #include <io.h>
+#else
+#include <unistd.h>
 #endif /* _WIN32 */
 
 #include "gif_lib.h"
@@ -74,7 +75,7 @@ int main(int argc, char **argv)
     int FD;
     int        NumFiles;
     bool Error, MinSizeFlag = false, HelpFlag = false;
-    char **FileName = NULL, FoutTmpName[STRLEN], FullPath[STRLEN], *p;
+    char **FileName = NULL, FoutTmpName[STRLEN+1], FullPath[STRLEN+1], *p;
     FILE *Fin, *Fout;
 
     if ((Error = GAGetArgs(argc, argv, CtrlStr, &GifNoisyPrint,
@@ -113,7 +114,6 @@ int main(int argc, char **argv)
     if ( *FileName == NULL ) GIF_EXIT("No valid Filename given.");
     if ( strlen(*FileName) > STRLEN-1 ) GIF_EXIT("Filename too long.");
     memset(FullPath, '\0', sizeof(FullPath));
-    // cppcheck-suppress redundantCopy
     strncpy(FullPath, *FileName, STRLEN);
     if ((p = strrchr(FullPath, '/')) != NULL ||
        (p = strrchr(FullPath, '\\')) != NULL)
@@ -161,10 +161,10 @@ int main(int argc, char **argv)
        fclose(Fout);
        unlink(*FileName);
        if (rename(FoutTmpName, *FileName) != 0) {
-           char DefaultName[STRLEN];
+           char DefaultName[STRLEN+1];
+           memset(DefaultName, '\0', sizeof(DefaultName));
            if ( (strlen(FullPath) + strlen(DEFAULT_OUT_NAME)) > STRLEN-1 ) GIF_EXIT("Filename too long.");
            strncpy(DefaultName, FullPath, STRLEN);
-           // cppcheck-suppress uninitstring
            strcat(DefaultName, DEFAULT_OUT_NAME);
            if (rename(FoutTmpName, DefaultName) == 0) {
                char s[STRLEN];