> term% mkdir trashdir && cd trashdir && mkdir x
> term% touch `{i=0; while (test $i -lt 128) { echo -n abcdefghijklmnop; 
> i=`{echo $i+1|hoc} } }
> term% cp abc* abc* x
> # watch the cp executable suicide
> # now, make SURE there's nothing in this rio window that you want to keep...
> term% rm abc*
> # watch the rio window go bye bye!

it used to be that path elements on the file server were limited
to 26 non-space characters.  if you're running ken, that limit
is typically 56 characters.  but fileservers (e.g. ramfs) are free
to choose any limit they wish.

i think fgb's fix is a good band-aid.  but we need to
be flexible and handle arbitrary sized file names.

i'm applying this.  i goto Again because i don't want
to break the rest of the glob.

; diffy -c plan9.c
/n/dump/2011/0201/sys/src/cmd/rc/plan9.c:443,448 - plan9.c:443,449
  int
  Readdir(int f, void *p, int onlydirs)
  {
+       char *s;
        int n;
  
        if(f<0 || f>=NFD)
/n/dump/2011/0201/sys/src/cmd/rc/plan9.c:465,472 - plan9.c:466,478
        }
        if(dir[f].i == dir[f].n)
                return 0;
-       strcpy(p, dir[f].dbuf[dir[f].i].name);
+       s = dir[f].dbuf[dir[f].i].name;
        dir[f].i++;
+       if(strlen(s) >= NDIR){
+               pfmt(err, "rc: file name too long: %s\n", s);
+               goto Again;
+       }
+       strcpy(p, s);
        return 1;
  }

- erik

Reply via email to