Group :: Sistema/Bibliotecas
RPM: libgif
Main Changelog Spec Patches Sources Download Gear Bugs e FR Repocop
Patch: libgif-4.1.6-alt-tmp.patch
Download
Download
--- giflib/configure.ac
+++ giflib/configure.ac
@@ -3,6 +3,7 @@
AC_CONFIG_SRCDIR([lib/dgif_lib.c])
AM_INIT_AUTOMAKE([gnu check-news dist-bzip2 -Wall])
AM_CONFIG_HEADER(config.h)
+AC_USE_SYSTEM_EXTENSIONS
dnl Checks for programs.
AC_PROG_LIBTOOL
--- giflib/util/gifinto.c
+++ giflib/util/gifinto.c
@@ -77,10 +77,9 @@
******************************************************************************/
int main(int argc, char **argv)
{
- int Error, NumFiles,
+ int Error, NumFiles, fd,
MinSizeFlag = FALSE, HelpFlag = FALSE;
- char **FileName = NULL,
- TmpName[80], FoutTmpName[80], FullPath[80], DefaultName[80], s[80], *p;
+ char **FileName = NULL, *FoutTmpName;
FILE *Fin, *Fout;
if ((Error = GAGetArgs(argc, argv, CtrlStr, &GifQuietPrint,
@@ -120,27 +119,9 @@ int main(int argc, char **argv)
}
#endif
- /* Isolate the directory where our destination is, and set tmp file name */
- /* in the very same directory. */
- strcpy(FullPath, *FileName);
- if ((p = strrchr(FullPath, '/')) != NULL ||
- (p = strrchr(FullPath, '\\')) != NULL)
- p[1] = 0;
- else if ((p = strrchr(FullPath, ':')) != NULL)
- p[1] = 0;
- else
- FullPath[0] = 0; /* No directory or disk specified. */
-
- strcpy(FoutTmpName, FullPath); /* Generate destination temporary name. */
- /* Make sure the temporary is made in the current directory: */
- p = tmpnam(TmpName);
- if (strrchr(p, '/')) p = strrchr(p, '/') + 1;
- if (strrchr(p, '\\')) p = strrchr(p, '\\') + 1;
- if (strlen(p) == 0) p = DEFAULT_TMP_NAME;
- strcat(FoutTmpName, p);
-
- Fout = fopen(FoutTmpName, "wb");
- if (Fout == NULL)
+ if ((asprintf(&FoutTmpName, "%s-XXXXXX", *FileName) < 0) ||
+ (fd = mkstemp(FoutTmpName)) < 0 ||
+ (Fout = fdopen(fd, "wb")) == NULL)
{
GIF_EXIT("Failed to open output.");
}
@@ -162,17 +143,8 @@ int main(int argc, char **argv)
fclose(Fout);
unlink(*FileName);
if (rename(FoutTmpName, *FileName) != 0) {
- strcpy(DefaultName, FullPath);
- strcat(DefaultName, DEFAULT_OUT_NAME);
- if (rename(FoutTmpName, DefaultName) == 0) {
- sprintf(s, "Failed to rename out file - left as %s.",
- DefaultName);
- GIF_MESSAGE(s);
- }
- else {
unlink(FoutTmpName);
GIF_MESSAGE("Failed to rename out file - deleted.");
- }
}
}
else {