Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ed: runtime error in edSubstitute() #577

Merged
merged 1 commit into from
Apr 24, 2024
Merged

Conversation

mknos
Copy link
Contributor

@mknos mknos commented Apr 24, 2024

  • The program crashes when fed unexpected input after the initial "s" command
  • I found this when investigating a capture-variable-outside-of-condition warning from perlcritic
  • $char is the 1st character after the "s"; normally it would be "/" as in s/old/new/
  • Return early if $args[0] is an empty string
  • Adding eval guard around the confusing regex constructed from $char prevents the error
  • Possibly the code could be changed later to enforce that $char is '/'
perl ed -p 'ed% ' a.c
63
ed% 1
#include <stdio.h>
ed% s*asaaa*
Unknown verb pattern '' in regex; marked by <-- HERE in m/((*) <-- HERE [^"*"]*(*)[^"*"]*(*)?)([imsx]*)/ at ed line 519, <> line 2.

* The program crashes when fed unexpected input after the initial "s" command
* I found this when investigating a capture-variable-outside-of-condition warning from perlcritic
* $char is the 1st character after the "s"; normally it would be "/" as in s/old/new/
* Return early if $args[0] is an empty string
* Adding eval guard around the confusing regex constructed from $char prevents the error
* Possibly the code could be changed later to enforce that $char is '/'

perl ed -p 'ed% ' a.c 
63
ed% 1
#include <stdio.h>
ed% s*asaaa*
Unknown verb pattern '' in regex; marked by <-- HERE in m/((*) <-- HERE [^"*"]*(*)[^"*"]*(*)?)([imsx]*)/ at ed line 519, <> line 2.
@github-actions github-actions bot added Type: enhancement improve a feature that already exists Priority: low get to this whenever Program: ed The ed program labels Apr 24, 2024
@briandfoy briandfoy self-assigned this Apr 24, 2024
@briandfoy
Copy link
Owner

briandfoy commented Apr 24, 2024

changes: handle argument to s command being zero length

@briandfoy briandfoy merged commit 1038b0e into briandfoy:master Apr 24, 2024
2 checks passed
@briandfoy briandfoy added Status: accepted The fix is accepted Status: released there is a new release with this fix and removed Priority: low get to this whenever Status: accepted The fix is accepted labels Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Program: ed The ed program Status: released there is a new release with this fix Type: enhancement improve a feature that already exists
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants