Skip to content

Commit

Permalink
ed: line 0 is invalid for write command (#658)
Browse files Browse the repository at this point in the history
* When testing previous commit I discovered this version of ed incorrectly accepts "0,1w file.mp3" command
* Address range 0-1 is not valid because lines count from 1
* Error was also not raised for "0w file.mp3", i.e. single-address mode
* Follow OpenBSD and GNU versions by printing invalid-address error
* Technically, ",1w file" command is valid because this is interpreted as implied range of "1,1" which is the same as just "1w"
  • Loading branch information
mknos authored Jun 25, 2024
1 parent af23c28 commit 7836a41
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bin/ed
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,10 @@ sub edWrite {
} elsif (defined($adrs[0]) && !defined($adrs[1])) {
$adrs[1] = $adrs[0];
}
if ($adrs[0] == 0) {
edWarn(E_ADDRBAD);
return;
}
if (length $commandsuf) {
if ($commandsuf eq 'q') {
$qflag = 1;
Expand Down

0 comments on commit 7836a41

Please sign in to comment.