1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
--- ./dos2unix.c.orig 2007-04-17 11:16:32.000000000 +0400
+++ ./dos2unix.c 2007-04-17 12:41:01.000000000 +0400
@@ -279,7 +279,7 @@
int RetVal = 0;
FILE *InF = NULL;
FILE *TempF = NULL;
- char TempPath[16];
+ char *TempPath = (char *) malloc(sizeof(char) * strlen(ipInFN)+14);
struct stat StatBuf;
struct utimbuf UTimeBuf;
int fd;
@@ -288,7 +288,8 @@
if ((ipFlag->KeepDate) && stat(ipInFN, &StatBuf))
RetVal = -1;
- strcpy (TempPath, "./d2utmpXXXXXX");
+ strcpy (TempPath, ipInFN);
+ strcat (TempPath, "_u2dtmpXXXXXX");
if((fd=mkstemp (TempPath))<0) {
perror("Failed to open output temp file");
RetVal = -1;
@@ -349,6 +350,7 @@
RetVal = -1;
}
}
+ free (TempPath);
return RetVal;
}
@@ -364,7 +366,7 @@
int RetVal = 0;
FILE *InF = NULL;
FILE *TempF = NULL;
- char TempPath[16];
+ char *TempPath = (char *) malloc(sizeof(char) * strlen(ipInFN)+14);
struct stat StatBuf;
struct utimbuf UTimeBuf;
mode_t mode = S_IRUSR | S_IWUSR;
@@ -376,7 +378,8 @@
else
mode = StatBuf.st_mode;
- strcpy (TempPath, "./u2dtmpXXXXXX");
+ strcpy (TempPath, ipInFN);
+ strcat (TempPath, "_u2dtmpXXXXXX");
if((fd=mkstemp (TempPath))<0) {
perror("Failed to open output temp file");
RetVal = -1;
@@ -442,6 +445,7 @@
}
RetVal = -1;
}
+ free (TempPath);
return RetVal;
}
|