- Applied patch from bug #292100 to fix segfault with missing -c argument.

This commit is contained in:
Tim Waugh 2008-01-18 09:27:14 +00:00
parent c4a9b95103
commit 77a01b8430
2 changed files with 48 additions and 1 deletions

View File

@ -0,0 +1,42 @@
diff -up dos2unix-3.1/dos2unix.c.c-missing-arg dos2unix-3.1/dos2unix.c
--- dos2unix-3.1/dos2unix.c.c-missing-arg 2008-01-18 09:24:21.000000000 +0000
+++ dos2unix-3.1/dos2unix.c 2008-01-18 09:25:43.000000000 +0000
@@ -533,19 +533,28 @@ int main (int argc, char *argv[])
if ((strcmp(argv[ArgIdx],"-c") == 0) || (strcmp(argv[ArgIdx],"--convmode") == 0))
{
- ArgIdx++;
- if (strcmpi(argv[ArgIdx],"ASCII") == 0)
- pFlag->ConvMode = 0;
- else if (strcmpi(argv[ArgIdx], "7Bit") == 0)
- pFlag->ConvMode = 1;
- else if (strcmpi(argv[ArgIdx], "ISO") == 0)
- pFlag->ConvMode = 2;
- else if (strcmpi(argv[ArgIdx], "Mac") == 0)
- pFlag->ConvMode = 3;
+ if (++ArgIdx < argc)
+ {
+ if (strcmpi(argv[ArgIdx],"ASCII") == 0)
+ pFlag->ConvMode = 0;
+ else if (strcmpi(argv[ArgIdx], "7Bit") == 0)
+ pFlag->ConvMode = 1;
+ else if (strcmpi(argv[ArgIdx], "ISO") == 0)
+ pFlag->ConvMode = 2;
+ else if (strcmpi(argv[ArgIdx], "Mac") == 0)
+ pFlag->ConvMode = 3;
+ else
+ {
+ if (!pFlag->Quiet)
+ fprintf(stderr, "dos2unix: invalid %s conversion mode specified\n",argv[ArgIdx]);
+ ShouldExit = 1;
+ }
+ }
else
{
+ ArgIdx--;
if (!pFlag->Quiet)
- fprintf(stderr, "dos2unix: invalid %s conversion mode specified\n",argv[ArgIdx]);
+ fprintf(stderr,"dos2unix: option `%s' requires an argument\n",argv[ArgIdx]);
ShouldExit = 1;
}
}

View File

@ -1,7 +1,7 @@
Summary: Text file format converter
Name: dos2unix
Version: 3.1
Release: 29%{?dist}
Release: 30%{?dist}
Group: Applications/Text
License: Freely distributable
Source: %{name}-%{version}.tar.bz2
@ -11,6 +11,7 @@ Patch2: dos2unix-3.1-safeconv.patch
Patch3: dos2unix-3.1-manpage-update-57507.patch
Patch4: dos2unix-3.1-preserve-file-modes.patch
Patch5: dos2unix-3.1-tmppath.patch
Patch6: dos2unix-c-missing-arg.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -25,6 +26,7 @@ Dos2unix converts DOS or MAC text files to UNIX format.
%patch3 -p1 -b .manpage-update-57507
%patch4 -p1 -b .preserve-file-modes
%patch5 -p1 -b .tmppath
%patch6 -p1 -b .c-missing-arg
for I in *.[ch]; do
sed -e 's,#endif.*,#endif,g' -e 's,#else.*,#else,g' $I > $I.new
@ -57,6 +59,9 @@ install -p -m444 mac2unix.1 $RPM_BUILD_ROOT%{_mandir}/man1
rm -rf $RPM_BUILD_ROOT
%changelog
* Fri Jan 18 2008 Tim Waugh <twaugh@redhat.com> 3.1-30
- Applied patch from bug #292100 to fix segfault with missing -c argument.
* Wed Aug 29 2007 Tim Waugh <twaugh@redhat.com> 3.1-29
- Rebuild.