84 lines
3.7 KiB
Plaintext
84 lines
3.7 KiB
Plaintext
--- jhead.c.orig.port Tue Jun 6 18:08:43 2023
|
|
+++ jhead.c Thu Jun 8 07:50:46 2023
|
|
@@ -286,7 +286,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;
|
|
}
|
|
@@ -318,8 +319,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;
|
|
}
|
|
|
|
@@ -662,7 +665,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");
|
|
@@ -678,7 +682,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);
|
|
}
|
|
|
|
@@ -722,7 +726,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
|
|
@@ -756,7 +761,8 @@
|
|
// Unknown orientation, but still modified.
|
|
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;
|
|
@@ -775,7 +781,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);
|
|
|
|
// Disallow characters in the filenames that could be used to execute arbitrary
|
|
@@ -1187,7 +1194,7 @@
|
|
|
|
// Print to temp buffer first to avoid putting null termination in destination.
|
|
// snprintf() would do the trick, but 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);
|
|
|