6l: Aconv safety Reference: /n/atom/patch/applied/ldaconvsafe Date: Sun Aug 16 04:02:31 CES 2015 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/6l/list.c Sun Aug 16 04:02:21 2015 +++ /sys/src/cmd/6l/list.c Sun Aug 16 04:02:23 2015 @@ -50,12 +50,31 @@ return fmtstrcpy(fp, str); } +static int lastaname; + +static void +aconvinit(void) +{ + if(lastaname > 0) + return; + for(;; lastaname++) + if(strcmp(anames[lastaname], "LAST") == 0) + break; +} + int Aconv(Fmt *fp) { + char buf[32]; int i; + aconvinit(); + i = va_arg(fp->args, int); + if(i < 0 || i > lastaname){ + snprint(buf, sizeof buf, "[aname %d]", i); + return fmtstrcpy(fp, buf); + } return fmtstrcpy(fp, anames[i]); } @@ -354,7 +373,7 @@ print("%s: %s\n", tn, buf); nerrors++; - if(nerrors > 20) { + if(nerrors > 20 && !debug['A']) { print("too many errors\n"); errorexit(); }