Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/dist/cdk Use bounded string op (snprintf instead of sprintf)...
details: https://anonhg.NetBSD.org/src/rev/f0ac8e4bd9b4
branches: trunk
changeset: 551056:f0ac8e4bd9b4
user: agc <agc%NetBSD.org@localhost>
date: Thu Aug 28 11:32:33 2003 +0000
description:
Use bounded string op (snprintf instead of sprintf) for an automatic
array which is used to calculate the maximum width of a scroll entry
item. Previous use of sprintf would blindly overwrite the stack if
there were more than 100 characters in an entry item.
diffstat:
dist/cdk/scroll.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diffs (34 lines):
diff -r 46998e5fecd2 -r f0ac8e4bd9b4 dist/cdk/scroll.c
--- a/dist/cdk/scroll.c Thu Aug 28 10:58:37 2003 +0000
+++ b/dist/cdk/scroll.c Thu Aug 28 11:32:33 2003 +0000
@@ -1,9 +1,9 @@
#include <cdk.h>
/*
- * $Author: garbled $
- * $Date: 2001/01/09 18:41:54 $
- * $Revision: 1.3 $
+ * $Author: agc $
+ * $Date: 2003/08/28 11:32:33 $
+ * $Revision: 1.4 $
*/
/*
@@ -754,7 +754,7 @@
{
for (x=0 ; x < listSize; x++)
{
- sprintf (temp, "%4d. %s", x + 1, list[x]);
+ snprintf (temp, sizeof(temp), "%4d. %s", x + 1, list[x]);
scrollp->item[x] = char2Chtype (temp, &scrollp->itemLen[x], &scrollp->itemPos[x]);
scrollp->itemPos[x] = justifyString (scrollp->fieldWidth, scrollp->itemLen[x], scrollp->itemPos[x]);
widestItem = MAXIMUM (widestItem, scrollp->itemLen[x]);
@@ -864,7 +864,7 @@
*/
if (scrollp->numbers == NUMBERS)
{
- sprintf (temp, "%4d. %s", itemNumber + 1, item);
+ snprintf (temp, sizeof(temp), "%4d. %s", itemNumber + 1, item);
scrollp->item[itemNumber] = char2Chtype (temp, &scrollp->itemLen[itemNumber], &scrollp->itemPos[itemNumber]);
scrollp->itemPos[itemNumber] = justifyString (scrollp->fieldWidth, scrollp->itemLen[itemNumber], scrollp->itemPos[itemNumber]);
}
Home |
Main Index |
Thread Index |
Old Index