]> git.pld-linux.org Git - packages/dos2unix.git/blob - dos2unix-segfault.patch
- rel 18 for fc2 upgrade
[packages/dos2unix.git] / dos2unix-segfault.patch
1 --- dos2unix-3.1/dos2unix.c.segf        Thu Jan 17 17:27:42 2002
2 +++ dos2unix-3.1/dos2unix.c     Thu Jan 17 17:28:07 2002
3 @@ -147,9 +147,9 @@
4   * RetVal: NULL if failure
5   *         file stream otherwise
6   */
7 -FILE* OpenOutFile(char *ipFN)
8 +FILE* OpenOutFile(int fd)
9  {
10 -  return (fopen(ipFN, W_CNTRL));
11 +  return (fdopen(fd, W_CNTRL));
12  }
13  
14  
15 @@ -260,14 +260,17 @@
16    char TempPath[16];
17    struct stat StatBuf;
18    struct utimbuf UTimeBuf;
19 +  int fd;
20  
21    /* retrieve ipInFN file date stamp */
22    if ((ipFlag->KeepDate) && stat(ipInFN, &StatBuf))
23      RetVal = -1;
24  
25 -  strcpy (TempPath, "./d2utmp");
26 -  strcat (TempPath, "XXXXXX");
27 -  mkstemp (TempPath);
28 +  strcpy (TempPath, "./d2utmpXXXXXX");
29 +  if((fd=mkstemp (TempPath))<0) {
30 +         perror("Failed to open output temp file");
31 +         RetVal = -1;
32 +  }
33  
34  #ifdef DEBUG
35    fprintf(stderr, "dos2unix: using %s as temp file\n", TempPath);
36 @@ -278,7 +281,7 @@
37      RetVal = -1;
38  
39    /* can open out file? */
40 -  if ((!RetVal) && (InF) && ((TempF=OpenOutFile(TempPath)) == NULL))
41 +  if ((!RetVal) && (InF) && ((TempF=OpenOutFile(fd)) == NULL))
42    {
43      fclose (InF);
44      RetVal = -1;
45 @@ -295,6 +298,8 @@
46    /* can close out file? */
47    if ((TempF) && (fclose(TempF) == EOF))
48      RetVal = -1;
49 +  if(fd>=0)
50 +         close(fd);
51  
52    if ((!RetVal) && (ipFlag->KeepDate))
53    {
54 @@ -340,14 +345,17 @@
55    char TempPath[16];
56    struct stat StatBuf;
57    struct utimbuf UTimeBuf;
58 +  int fd;
59  
60    /* retrieve ipInFN file date stamp */
61    if ((ipFlag->KeepDate) && stat(ipInFN, &StatBuf))
62      RetVal = -1;
63  
64 -  strcpy (TempPath, "./u2dtmp");
65 -  strcat (TempPath, "XXXXXX");
66 -  mkstemp (TempPath);
67 +  strcpy (TempPath, "./u2dtmpXXXXXX");
68 +  if((fd=mkstemp (TempPath))<0) {
69 +         perror("Failed to open output temp file");
70 +         RetVal = -1;
71 +  }
72  
73  #ifdef DEBUG
74    fprintf(stderr, "dos2unix: using %s as temp file\n", TempPath);
75 @@ -358,7 +366,7 @@
76      RetVal = -1;
77  
78    /* can open out file? */
79 -  if ((!RetVal) && (InF) && ((TempF=OpenOutFile(TempPath)) == NULL))
80 +  if ((!RetVal) && (InF) && ((TempF=OpenOutFile(fd)) == NULL))
81    {
82      fclose (InF);
83      RetVal = -1;
84 @@ -376,6 +384,9 @@
85    if ((TempF) && (fclose(TempF) == EOF))
86      RetVal = -1;
87  
88 +  if(fd>=0)
89 +         close(fd);
90 +
91    if ((!RetVal) && (ipFlag->KeepDate))
92    {
93      UTimeBuf.actime = StatBuf.st_atime;
This page took 0.034918 seconds and 3 git commands to generate.