123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- --- jhead.c.orig Mon Feb 2 23:24:06 2015
- +++ jhead.c Wed Feb 4 07:43:36 2015
- @@ -164,7 +164,8 @@
- }
- if (strlen(Editor) > PATH_MAX) ErrFatal("env too long");
-
- - sprintf(QuotedPath, "%s \"%s\"",Editor, TempFileName);
- + snprintf(QuotedPath, sizeof(QuotedPath), "%s \"%s\"",Editor,
- + TempFileName);
- a = system(QuotedPath);
- }
-
- @@ -271,7 +272,8 @@
- if (!HasScandate && !ImageInfo.DateTime[0]){
- // Scan date is not in the file yet, and it doesn't have one built in. Add it.
- char Temp[40];
- - sprintf(Temp, "scan_date=%s", ctime(&ImageInfo.FileDateTime));
- + snprintf(Temp, sizeof(Temp),
- + "scan_date=%s", ctime(&ImageInfo.FileDateTime));
- strncat(OutComment, Temp, MAX_COMMENT_SIZE-5-strlen(OutComment));
- Modified = TRUE;
- }
- @@ -303,8 +305,10 @@
-
- if (scale < 0.4) scale = 0.4; // Don't scale down by too much.
-
- - sprintf(CommandString, "mogrify -geometry %dx%d -quality 85 &i",(int)(ImageInfo.Width*scale+0.5),
- - (int)(ImageInfo.Height*scale+0.5));
- + snprintf(CommandString, sizeof(CommandString),
- + "mogrify -geometry %dx%d -quality 85 &i",
- + (int)(ImageInfo.Width*scale+0.5), (int)(ImageInfo.Height*scale+0.5));
- +
- return TRUE;
- }
-
- @@ -625,7 +629,8 @@
- memcpy(pat, pattern+ppos, 4);
- pat[a-ppos] = 'd'; // Replace 'i' with 'd' for '%d'
- pat[a-ppos+1] = '\0';
- - sprintf(num, pat, FileSequence); // let printf do the number formatting.
- + // let printf do the number formatting.
- + snprintf(num, sizeof(num), pat, FileSequence);
- nl = strlen(num);
- l = strlen(pattern+a+1);
- if (ppos+nl+l+1 >= PATH_MAX) ErrFatal("str overflow");
- @@ -641,7 +646,7 @@
- strftime(NewName, PATH_MAX, pattern, &tm);
- }else{
- // My favourite scheme.
- - sprintf(NewName, "%02d%02d-%02d%02d%02d",
- + snprintf(NewName, sizeof(NewName), "%02d%02d-%02d%02d%02d",
- tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
- }
-
- @@ -670,7 +675,7 @@
- NameExtra[0] = 0;
- }
-
- - sprintf(NewName, "%s%s.jpg", NewBaseName, NameExtra);
- + snprintf(NewName, sizeof(NewName), "%s%s.jpg", NewBaseName, NameExtra);
-
- if (!strcmp(FileName, NewName)) break; // Skip if its already this name.
-
- @@ -685,7 +690,8 @@
- printf("%s --> %s\n",FileName, NewName);
- #ifdef _WIN32
- if (RenameAssociatedFiles){
- - sprintf(NewName, "%s%s", NewBaseName, NameExtra);
- + snprintf(NewName, sizeof(NewName),
- + "%s%s", NewBaseName, NameExtra);
- RenameAssociated(FileName, NewName);
- }
- #endif
- @@ -718,7 +724,8 @@
- ErrNonfatal("Unknown orientation tag",0,0);
- return TRUE; // Image is still modified.
- }
- - sprintf(RotateCommand, "jpegtran -trim -%s -outfile &o &i", Argument);
- + snprintf(RotateCommand, sizeof(RotateCommand),
- + "jpegtran -trim -%s -outfile &o &i", Argument);
- ApplyCommand = RotateCommand;
- DoCommand(FileName, FALSE);
- ApplyCommand = NULL;
- @@ -737,7 +744,8 @@
- strcpy(ThumbTempName_out, FileName);
- strcat(ThumbTempName_out, ".tho");
- SaveThumbnail(ThumbTempName_in);
- - sprintf(RotateCommand,"jpegtran -trim -%s -outfile \"%s\" \"%s\"",
- + snprintf(RotateCommand, sizeof(RotateCommand),
- + "jpegtran -trim -%s -outfile \"%s\" \"%s\"",
- Argument, ThumbTempName_out, ThumbTempName_in);
-
- if (system(RotateCommand) == 0){
- @@ -765,7 +773,8 @@
- return FALSE;
- }
-
- - sprintf(ThumbnailGenCommand, "mogrify -thumbnail %dx%d \"%s\"",
- + snprintf(ThumbnailGenCommand, sizeof(ThumbnailGenCommand),
- + "mogrify -thumbnail %dx%d \"%s\"",
- RegenThumbnail, RegenThumbnail, FileName);
-
- if (system(ThumbnailGenCommand) == 0){
- @@ -1134,7 +1143,7 @@
-
- // Print to temp buffer first to avoid putting null termination in destination.
- // snprintf() would do the trick, hbut not available everywhere (like FreeBSD 4.4)
- - sprintf(TempBuf, "%04d:%02d:%02d %02d:%02d:%02d",
- + snprintf(TempBuf, sizeof(TempBuf), "%04d:%02d:%02d %02d:%02d:%02d",
- tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
- tm.tm_hour, tm.tm_min, tm.tm_sec);
-
|