The sprint removal patch for the boot directory. Reference: /n/sources/patch/saved/remove-sprint-boot Date: Fri Feb 25 22:21:12 CET 2011 Signed-off-by: 20h@r-36.net --- /sys/src/9/boot/settime.c Fri Feb 25 22:16:47 2011 +++ /sys/src/9/boot/settime.c Fri Feb 25 22:16:44 2011 @@ -50,7 +50,7 @@ if(stat("/tmp", statbuf, sizeof statbuf) < 0) fatal("stat"); convM2D(statbuf, sizeof statbuf, &dir[0], (char*)&dir[1]); - sprint(timebuf, "%ld", dir[0].atime); + snprint(timebuf, sizeof(timebuf), "%ld", dir[0].atime); unmount(0, "/tmp"); } @@ -144,6 +144,6 @@ if(*buf) secs += g2(&buf); - sprint(argbuf, "%ld", secs); + snprint(argbuf, 64, "%ld", secs); /* buffer size taken from timebuf above. */ return secs; } --- /sys/src/9/boot/sac.c Fri Feb 25 22:16:53 2011 +++ /sys/src/9/boot/sac.c Fri Feb 25 22:16:50 2011 @@ -36,7 +36,7 @@ write(fd, "brick", 5); close(fd); - sprint(cmd, "/%s/init", cputype); + snprint(cmd, sizeof(cmd), "/%s/init", cputype); print("starting %s\n", cmd); execl(cmd, "init", "-c", 0); fatal(cmd); --- /sys/src/9/boot/local.c Fri Feb 25 22:16:59 2011 +++ /sys/src/9/boot/local.c Fri Feb 25 22:16:56 2011 @@ -25,7 +25,7 @@ */ p = strchr(argv0, ','); n = strtoul(p+1, 0, 10); - sprint(diskname, "#w%d/sd%dfs", n, n); + snprint(diskname, sizeof(diskname), "#w%d/sd%dfs", n, n); disk = diskname; } else if(mp->arg){ /* --- /sys/src/9/boot/doauthenticate.c Fri Feb 25 22:17:04 2011 +++ /sys/src/9/boot/doauthenticate.c Fri Feb 25 22:17:02 2011 @@ -33,26 +33,26 @@ fatal("no method for accessing auth server"); afd = (*mp->auth)(); if(afd < 0) { - sprint(error, "%s: %r", ccmsg); + snprint(error, sizeof(error), "%s: %r", ccmsg); return error; } if(write(afd, trbuf, TICKREQLEN) < 0 || read(afd, &t, 1) != 1){ close(afd); - sprint(error, "%s: %r", pbmsg); + snprint(error, sizeof(error), "%s: %r", pbmsg); return error; } switch(t){ case AuthOK: msg = 0; if(readn(afd, tbuf, 2*TICKETLEN) < 0) { - sprint(error, "%s: %r", pbmsg); + snprint(error, sizeof(error), "%s: %r", pbmsg); msg = error; } break; case AuthErr: if(readn(afd, error, ERRMAX) < 0) { - sprint(error, "%s: %r", pbmsg); + snprint(error, sizeof(error), "%s: %r", pbmsg); msg = error; } else { --- /sys/src/9/boot/bootcache.c Fri Feb 25 22:17:10 2011 +++ /sys/src/9/boot/bootcache.c Fri Feb 25 22:17:07 2011 @@ -42,12 +42,12 @@ bd[i-2] = 0; else if(strcmp("fossil", &bd[i-6]) == 0) bd[i-6] = 0; - sprint(partition, "%scache", bd); + snprint(partition, sizeof(partition), "%scache", bd); if(stat(partition, statbuf, sizeof statbuf) < 0) *bd = 0; } if(*bd == 0){ - sprint(partition, "%scache", bootdisk); + snprint(partition, sizeof(partition), "%scache", bootdisk); if(stat(partition, statbuf, sizeof statbuf) < 0) return fd; } --- /sys/src/9/boot/boot.c Fri Feb 25 22:17:16 2011 +++ /sys/src/9/boot/boot.c Fri Feb 25 22:17:13 2011 @@ -167,7 +167,7 @@ cmd = getenv("init"); if(cmd == nil){ - sprint(cmdbuf, "/%s/init -%s%s", cputype, + snprint(cmdbuf, sizeof(cmdbuf), "/%s/init -%s%s", cputype, cpuflag ? "c" : "t", mflag ? "m" : ""); cmd = cmdbuf; } @@ -233,10 +233,10 @@ /* make list of methods */ mp = method; - n = sprint(prompt, "root is from (%s", mp->name); + n = snprint(prompt, sizeof(prompt), "root is from (%s", mp->name); for(mp++; mp->name; mp++) - n += sprint(prompt+n, ", %s", mp->name); - sprint(prompt+n, ")"); + n += snprint(prompt+n, sizeof(prompt)-n, ", %s", mp->name); + snprint(prompt+n, sizeof(prompt)-n, ")"); /* create default reply */ readfile("#e/bootargs", reply, sizeof(reply));