ref: 4ae7a48e2303130a6634f6eef1f6d56118bbd6d1
parent: 058b4f1cf3c67a4aeae513d5520971042124d7f3
author: Alex Musolino <alex@musolino.id.au>
date: Sat Feb 1 04:50:01 EST 2025
webfs: fix crash in unquote function When unquote is called on a non-quoted string with no whitespace characters then strpbrk(2) returns nil and the subsequent assignment through p results in a crash.
--- a/sys/src/cmd/webfs/sub.c
+++ b/sys/src/cmd/webfs/sub.c
@@ -116,8 +116,14 @@
char *p;
if(*s != '"'){
- p = strpbrk(s, " \t\r\n");
- *p++ = 0;
+ p = s;
+ while(*p){
+ if(strchr(" \t\r\n", *p) != nil){
+ *p++ = 0;
+ break;
+ }
+ p++;
+ }
*ps = p;
return s;
}
--
⑨