From Bugzilla Helper: User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; X11; Linux i686) Opera 7.54 [en] Description of problem: unix2dos -n segfaults whenever the -n switch is used. This problem was not present in unix2dos-2.2-21. Version-Release number of selected component (if applicable): unix2dos-2.2-24 How reproducible: Always Steps to Reproduce: echo foo > foo.txt unix2dos -n foo.txt foo.txt.dos Actual Results: unix2dos: converting file foo.txt to file foo.txt. dos in DOS format ... zsh: segmentation fault unix2dos -n foo.txt foo.txt.dos Additional info: unix2dos-2.2-24 glibc-2.3.3-74 Linux lrrr 2.6.9-1.667smp #1 SMP Tue Nov 2 14:59:52 EST 2004 i686 i686 i386 GNU/Linux
(The debuginfo package would be more useful if the specfile compiles unix2dos with -g option) I quite like these clear, "small" bugs as they are easy to find with valgrind. Speaking of valgrind: unix2dos: converting file foo to file foo.txt.dos in DOS format ... ==5795== Use of uninitialised value of size 4 ==5795== at 0x1B902434: strcpy (mac_replace_strmem.c:198) ==5795== by 0x8048E46: ConvertUnixToDosNewFile (unix2dos.c:253) ==5795== by 0x8049794: main (unix2dos.c:510) ==5795== ==5795== Conditional jump or move depends on uninitialised value(s) ==5795== at 0x1B90244B: strcpy (mac_replace_strmem.c:72) ==5795== by 0x8048E46: ConvertUnixToDosNewFile (unix2dos.c:253) ==5795== by 0x8049794: main (unix2dos.c:510) ==5795== ==5795== Conditional jump or move depends on uninitialised value(s) ==5795== at 0x1B90246A: strcpy (mac_replace_strmem.c:81) ==5795== by 0x8048E46: ConvertUnixToDosNewFile (unix2dos.c:253) ==5795== by 0x8049794: main (unix2dos.c:510) ==5795== ==5795== Conditional jump or move depends on uninitialised value(s) ==5795== at 0x1B90247F: strcpy (mac_replace_strmem.c:69) ==5795== by 0x8048E46: ConvertUnixToDosNewFile (unix2dos.c:253) ==5795== by 0x8049794: main (unix2dos.c:510) The problem arises in the following: char *TempPath; struct stat StatBuf; struct utimbuf UTimeBuf; int fd; /* retrieve ipInFN file date stamp */ if ((ipFlag->KeepDate) && stat(ipInFN, &StatBuf)) RetVal = -1; strcpy (TempPath, "./u2dtmpXXXXXX"); if((fd = MakeTempFileFrom (ipOutFN, &TempPath)) < 0) { TempPath is not pointing to allocated memory for strcpy to copy into. Further MakeTempFileFrom only uses TempPath to return a string - it NULLs the pointer passed in early on so assinging anything to TempPath before calling it seems useless. Removing the strcpy seems to fix the problem.
I was just about to add a patch when I noticed that this problem appears to be due to a change in unix2dos-2.2-tmppath.patch . On line 59 of the patch, when TempPath[16] was changed to *TempPath the strcpy was broken but this is not a big deal because the strcpy is no longer needed because of the change to use MakeTempFileFrom.
Created attachment 109817 [details] Patch to fix gcc warnings A small patch that adds brackets to quieten gcc. The binary compiled is identical to the one without brackets and I'm fairly sure the logic is correct because the line format effectively suggests how the expression was meant to be read.
*** This bug has been marked as a duplicate of 153079 ***