On Fri, Jan 05, 2001 at 12:22:05AM +0100, Ivo Vollrath wrote:
> Hi,
>
> I have strange trouble with coda 5.3.8 and 5.3.10:
> After having created the 12th volume, the output of the
> command
> # volutil getvolumelist
> is garbled: the line with the last volume contains some
> non-printable binary characters. This breaks createvol_rep
> and seems to be an evil thing anyway.
>
> Has anybody seen this behaviour before or does anybody
> know a fix?
Bug in the snprintf implementation in libc, here is a workaround.
Jan
Index: volume.cc
===================================================================
RCS file: /afs/cs/project/coda-src/cvs/coda/coda-src/vol/volume.cc,v
retrieving revision 4.43
retrieving revision 4.46
diff -u -u -r4.43 -r4.46
--- volume.cc 2000/08/04 01:00:23 4.43
+++ volume.cc 2000/10/16 10:15:57 4.46
@@ -526,9 +526,13 @@
V_parentId(vp), V_creationDate(vp), V_copyDate(vp),
V_backupDate(vp), volumeusage);
+ /* hack, snprintf sometimes fucks up and doesn't return -1 */
+ if (n >= (int)(*buflen - *offset)) n = -1;
+
if (n == -1) {
*buflen += 1024;
*buf = (char *)realloc(*buf, *buflen);
+ CODA_ASSERT(*buf);
goto retry;
}
*offset += n;
@@ -552,9 +556,14 @@
retry:
n = snprintf(*buf + *offset, buflen - *offset, "P%s H%s T%x F%x\n",
part->name, ThisHost, part->totalUsable, part->free);
+
+ /* hack, snprintf sometimes fucks up and doesn't return -1 */
+ if (n >= (int)(buflen - *offset)) n = -1;
+
if (n == -1) {
buflen += 1024;
*buf = (char *)realloc(*buf, buflen);
+ CODA_ASSERT(*buf);
goto retry;
}
*offset += n;