Module Name: src
Committed By: bouyer
Date: Sun Jan 30 00:21:08 UTC 2011
Modified Files:
src/usr.bin/quota [bouyer-quota2]: printquota.c
Log Message:
intprt() can be called up to 3 times for a single printf();
make sure to return 3 different static buffers in such a case.
To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/usr.bin/quota/printquota.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/quota/printquota.c
diff -u src/usr.bin/quota/printquota.c:1.1.2.2 src/usr.bin/quota/printquota.c:1.1.2.3
--- src/usr.bin/quota/printquota.c:1.1.2.2 Sat Jan 29 17:42:37 2011
+++ src/usr.bin/quota/printquota.c Sun Jan 30 00:21:08 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: printquota.c,v 1.1.2.2 2011/01/29 17:42:37 bouyer Exp $ */
+/* $NetBSD: printquota.c,v 1.1.2.3 2011/01/30 00:21:08 bouyer Exp $ */
/*
* Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)quota.c 8.4 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: printquota.c,v 1.1.2.2 2011/01/29 17:42:37 bouyer Exp $");
+__RCSID("$NetBSD: printquota.c,v 1.1.2.3 2011/01/30 00:21:08 bouyer Exp $");
#endif
#endif /* not lint */
@@ -67,8 +67,15 @@
const char *
intprt(uint64_t val, u_int flags, int hflag)
{
- static char buf[21];
-
+#define NBUFS 3
+ static char bufs[NBUFS][21];
+ char *buf;
+ static int i = 0;
+
+ buf = bufs[i++];
+ if (i == NBUFS)
+ i = 0;
+#undef NBUFS
if (val == UQUAD_MAX)
return((flags & HN_PRIV_UNLIMITED) ? "unlimited" : "-");