ref: d79b89a90537cc7ee615b3cc14995684fc583b50
parent: fc518b87238f49a4229b965ab406d6d188c9d890
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;
}
--
⑨