Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/bouyer-quota2]: src/usr.bin/quota intprt() can be called up to 3 times f...
details: https://anonhg.NetBSD.org/src/rev/35207ef402c1
branches: bouyer-quota2
changeset: 761081:35207ef402c1
user: bouyer <bouyer%NetBSD.org@localhost>
date: Sun Jan 30 00:21:08 2011 +0000
description:
intprt() can be called up to 3 times for a single printf();
make sure to return 3 different static buffers in such a case.
diffstat:
usr.bin/quota/printquota.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diffs (35 lines):
diff -r 63e2b7fceb10 -r 35207ef402c1 usr.bin/quota/printquota.c
--- a/usr.bin/quota/printquota.c Sat Jan 29 23:22:00 2011 +0000
+++ b/usr.bin/quota/printquota.c Sun Jan 30 00:21:08 2011 +0000
@@ -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" : "-");
Home |
Main Index |
Thread Index |
Old Index