This is a fix of jukefs, where there could have happen a reread() on a static buffer, which Plan9 does not allow. This patch was done in a distributed manner on IRC, with some beer, red wine and across four countries. Notes: Fri Apr 8 11:02:38 EDT 2005 rsc This would have been a lot easier to follow with a better explanation. reread() doesn't take any arguments at all. The problem is that mapname, which might point at an argument or a static string, is assumed to be a 256-byte buffer, which it isn't. Thanks for the patch. Reference: /n/sources/patch/applied/jukefs-mapname Date: Wed Apr 6 20:32:36 CES 2005 Reviewed-by: rsc --- /sys/src/games/music/jukefs/server.c Wed Apr 6 20:32:00 2005 +++ /sys/src/games/music/jukefs/server.c Wed Apr 6 20:31:55 2005 @@ -131,10 +131,11 @@ if((f = Bopen(mapname, OREAD)) == nil) sysfatal("%s: %r", mapname); - strncpy(file, mapname, 256); - if ((q = strrchr(mapname, '/'))) *q = 0; + file = strdup(mapname); + if ((q = strrchr(file, '/'))) *q = 0; inittokenlist(); - startdir = q?mapname:""; + startdir = strdup(q?file:""); + free(file); getobject(Root, nil); Bterm(f); f = nil; @@ -178,7 +179,7 @@ char *q; assert(f == nil); - if((f = Bopen(file, OREAD)) == nil) + if((f = Bopen(mapname, OREAD)) == nil) fprint(2, "reread: %s: %r\n", file); freetree(root); root = nil; @@ -194,9 +195,10 @@ tokenlist = nil; ntoken = Ntoken; inittokenlist(); - strncpy(mapname, file, 256); - if ((q = strrchr(mapname, '/'))) *q = 0; - startdir = q?mapname:""; + file = strdup(mapname); + if ((q = strrchr(file, '/'))) *q = 0; + startdir = strdup(q?file:""); + free(file); getobject(Root, nil); root->parent = root; Bterm(f); --- /sys/src/games/music/jukefs/parse.c Wed Apr 6 20:32:20 2005 +++ /sys/src/games/music/jukefs/parse.c Wed Apr 6 20:32:14 2005 @@ -165,7 +165,7 @@ o->flags |= Hier; if(parent == nil){ root = o; - o->path = strdup(startdir); + o->path = startdir; setmalloctag(o->path, 0x100001); } if(gettoken(token) != BraceO)