Article View: comp.bugs.2bsd
Article #211Re: 'sed -e' dumps core
From: David Elliott
Date: Sat, 03 Sep 1988 15:11
Date: Sat, 03 Sep 1988 15:11
65 lines
2297 bytes
2297 bytes
In article <15741@shemp.CS.UCLA.EDU> casey@admin.cognet.ucla.edu.UUCP (Casey Leedom) writes:
>In article <1334@solo7.cs.vu.nl> maart@cs.vu.nl () writes:
>> 'sed -e' without any further argument dumps core. A fix should be easy.
>
> What version of 2BSD are you using? I just did this on our current
>2.10BSD (soon to be released at the site near you) and didn't have any
>problems. Are you using 2.9BSD?
If you're on a DEC machine, or any machine that allows dereferencing of
NULL pointers, it probably works fine.
This is one of those long-standing problems, and is present in both
BSD and System V. There are actually 2 bugs. In the -f code, the
check for enough arguments left checks to see if eargc is 1 and then
decrements it, exiting if it isn't, but eargc can't be 1 at that point.
The -e code doesn't even check for enough arguments in System V, but
I seem to remember it does the same as for -f in BSD.
Here's the fix for System V (the BSD code should be similar):
*** sed0.c.old
--- sed0.c
***************
*** 97,106 ****
continue;
case 'f':
! if(eargc-- <= 0) exit(2);
if((fin = fopen(*++eargv, "r")) == NULL) {
! fprintf(stderr, "Cannot open pattern-file: %s\n", *eargv);
exit(2);
}
--- 97,110 ----
continue;
case 'f':
! if (eargc < 2) {
! fprintf(stderr, "-f requires a file argument\n");
! exit(2);
! }
! eargc--;
if((fin = fopen(*++eargv, "r")) == NULL) {
! perror(*eargv);
exit(2);
}
***************
*** 109,114 ****
--- 113,122 ----
continue;
case 'e':
+ if (eargc < 2) {
+ fprintf(stderr, "-e requires an argument\n");
+ exit(2);
+ }
eflag++;
fcomp();
eflag = 0;
--
David Elliott dce@mips.com or {ames,prls,pyramid,decwrl}!mips!dce
Technical Details
Message-ID:
<3035@dunkshot.mips.COM>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!mailrus!ames!vsi1!wyse!mips!dceReferences:
<1334@solo7.cs.vu.nl> <15741@shemp.CS.UCLA.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!mailrus!ames!vsi1!wyse!mips!dce From: dce@mips.COM (David Elliott) Newsgroups: comp.bugs.2bsd,comp.bugs.4bsd,comp.bugs.sys5 Subject: Re: 'sed -e' dumps core Message-ID: <3035@dunkshot.mips.COM> Date: 3 Sep 88 15:11:25 GMT References: <1334@solo7.cs.vu.nl> <15741@shemp.CS.UCLA.EDU> Reply-To: dce@dunkshot.UUCP (David Elliott) Organization: MIPS Computer Systems, Sunnyvale, CA Lines: 65