a6cd7eb8a1
svn path=/nixpkgs/trunk/; revision=19409
94 lines
2.2 KiB
Diff
94 lines
2.2 KiB
Diff
--- unix2dos-2.2/unix2dos.c.segf Thu Jan 17 17:09:49 2002
|
|
+++ unix2dos-2.2/unix2dos.c Thu Jan 17 17:12:47 2002
|
|
@@ -131,9 +131,9 @@
|
|
* RetVal: NULL if failure
|
|
* file stream otherwise
|
|
*/
|
|
-FILE* OpenOutFile(char *ipFN)
|
|
+FILE* OpenOutFile(int fd)
|
|
{
|
|
- return (fopen(ipFN, W_CNTRL));
|
|
+ return (fdopen(fd, W_CNTRL));
|
|
}
|
|
|
|
|
|
@@ -207,14 +207,17 @@
|
|
char TempPath[16];
|
|
struct stat StatBuf;
|
|
struct utimbuf UTimeBuf;
|
|
+ int fd;
|
|
|
|
/* retrieve ipInFN file date stamp */
|
|
if ((ipFlag->KeepDate) && stat(ipInFN, &StatBuf))
|
|
RetVal = -1;
|
|
|
|
- strcpy (TempPath, "./u2dtmp");
|
|
- strcat (TempPath, "XXXXXX");
|
|
- mkstemp (TempPath);
|
|
+ strcpy (TempPath, "./u2dtmpXXXXXX");
|
|
+ if((fd=mkstemp (TempPath)) < 0) {
|
|
+ perror("Can't open output temp file");
|
|
+ RetVal = -1;
|
|
+ }
|
|
|
|
#ifdef DEBUG
|
|
fprintf(stderr, "unix2dos: using %s as temp file\n", TempPath);
|
|
@@ -225,7 +228,7 @@
|
|
RetVal = -1;
|
|
|
|
/* can open out file? */
|
|
- if ((!RetVal) && (InF) && ((TempF=OpenOutFile(TempPath)) == NULL))
|
|
+ if ((!RetVal) && (InF) && ((TempF=OpenOutFile(fd)) == NULL))
|
|
{
|
|
fclose (InF);
|
|
RetVal = -1;
|
|
@@ -243,6 +246,9 @@
|
|
if ((TempF) && (fclose(TempF) == EOF))
|
|
RetVal = -1;
|
|
|
|
+ if(fd>=0)
|
|
+ close(fd);
|
|
+
|
|
if ((!RetVal) && (ipFlag->KeepDate))
|
|
{
|
|
UTimeBuf.actime = StatBuf.st_atime;
|
|
@@ -286,14 +292,17 @@
|
|
char TempPath[16];
|
|
struct stat StatBuf;
|
|
struct utimbuf UTimeBuf;
|
|
+ int fd;
|
|
|
|
/* retrieve ipInFN file date stamp */
|
|
if ((ipFlag->KeepDate) && stat(ipInFN, &StatBuf))
|
|
RetVal = -1;
|
|
|
|
- strcpy (TempPath, "./u2dtmp");
|
|
- strcat (TempPath, "XXXXXX");
|
|
- mkstemp (TempPath);
|
|
+ strcpy (TempPath, "./u2dtmpXXXXXX");
|
|
+ if((fd=mkstemp (TempPath)) < 0) {
|
|
+ perror("Can't open output temp file");
|
|
+ RetVal = -1;
|
|
+ }
|
|
|
|
#ifdef DEBUG
|
|
fprintf(stderr, "unix2dos: using %s as temp file\n", TempPath);
|
|
@@ -304,7 +313,7 @@
|
|
RetVal = -1;
|
|
|
|
/* can open out file? */
|
|
- if ((!RetVal) && (InF) && ((TempF=OpenOutFile(TempPath)) == NULL))
|
|
+ if ((!RetVal) && (InF) && ((TempF=OpenOutFile(fd)) == NULL))
|
|
{
|
|
fclose (InF);
|
|
RetVal = -1;
|
|
@@ -322,6 +331,9 @@
|
|
if ((TempF) && (fclose(TempF) == EOF))
|
|
RetVal = -1;
|
|
|
|
+ if(fd>=0)
|
|
+ close(fd);
|
|
+
|
|
if ((!RetVal) && (ipFlag->KeepDate))
|
|
{
|
|
UTimeBuf.actime = StatBuf.st_atime;
|