ref: 12e136332a7dcb6e4d0b4a85fef9ff97dfa57200
parent: ed3a3c4dd44efb92a1897baa4e07aa685227cddd
author: BurnZeZ <devnull@localhost>
date: Fri May 31 18:15:53 EDT 2019
plumber: loop will go out of bounds when *++s == '\0'; replace with strstr
--- a/sys/src/cmd/plumb/rules.c
+++ b/sys/src/cmd/plumb/rules.c
@@ -728,7 +728,7 @@
{
int n;
Ruleset *rs;
- uchar *otext, *s, *endofrule;
+ uchar *otext, *p;
pushinput("<rules input>", -1, text);
if(done)
@@ -738,15 +738,11 @@
* Help user by sending any full rules to parser so any parse errors will
* occur on write rather than close. A heuristic will do: blank line ends rule.
*/
- endofrule = nil;
- for(s=text; *s!='\0'; s++)
- if(*s=='\n' && *++s=='\n')
- endofrule = s+1;
- if(endofrule == nil){
+ if((p = (uchar*)strstr((char*)text, "\n\n")) == nil){
popinput();
return text;
}
- input->end = endofrule;
+ input->end = p+2;
}
for(n=0; rules[n]; n++)
;