summaryrefslogtreecommitdiff
path: root/lib/libcurses/trace
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libcurses/trace')
-rw-r--r--lib/libcurses/trace/lib_trace.c10
-rw-r--r--lib/libcurses/trace/lib_traceatr.c16
-rw-r--r--lib/libcurses/trace/lib_tracechr.c3
-rw-r--r--lib/libcurses/trace/lib_tracedmp.c18
-rw-r--r--lib/libcurses/trace/lib_tracemse.c6
5 files changed, 28 insertions, 25 deletions
diff --git a/lib/libcurses/trace/lib_trace.c b/lib/libcurses/trace/lib_trace.c
index 698c4b9e202..2089f0e4977 100644
--- a/lib/libcurses/trace/lib_trace.c
+++ b/lib/libcurses/trace/lib_trace.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_trace.c,v 1.6 2001/01/22 18:01:58 millert Exp $ */
+/* $OpenBSD: lib_trace.c,v 1.7 2003/03/17 19:16:59 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -88,6 +88,7 @@ NCURSES_EXPORT(const char *)
_nc_visbuf2(int bufnum, const char *buf)
/* visibilize a given string */
{
+ size_t vbsize;
char *vbuf;
char *tp;
int c;
@@ -97,12 +98,13 @@ _nc_visbuf2(int bufnum, const char *buf)
if (buf == CANCELLED_STRING)
return ("(cancelled)");
+ vbsize = (strlen(buf) * 4) + 5;
#ifdef TRACE
- tp = vbuf = _nc_trace_buf(bufnum, (strlen(buf) * 4) + 5);
+ tp = vbuf = _nc_trace_buf(bufnum, vbsize);
#else
{
static char *mybuf[2];
- mybuf[bufnum] = _nc_doalloc(mybuf[bufnum], (strlen(buf) * 4) + 5);
+ mybuf[bufnum] = _nc_doalloc(mybuf[bufnum], vbsize);
tp = vbuf = mybuf[bufnum];
}
#endif
@@ -130,7 +132,7 @@ _nc_visbuf2(int bufnum, const char *buf)
*tp++ = '^';
*tp++ = '@' + c;
} else {
- sprintf(tp, "\\%03o", CharOf(c));
+ snprintf(tp, vbsize - (tp - vbuf), "\\%03o", CharOf(c));
tp += strlen(tp);
}
}
diff --git a/lib/libcurses/trace/lib_traceatr.c b/lib/libcurses/trace/lib_traceatr.c
index d90d239de86..57c2ad5fc76 100644
--- a/lib/libcurses/trace/lib_traceatr.c
+++ b/lib/libcurses/trace/lib_traceatr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_traceatr.c,v 1.3 2001/01/22 18:01:58 millert Exp $ */
+/* $OpenBSD: lib_traceatr.c,v 1.4 2003/03/17 19:16:59 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -103,14 +103,14 @@ _traceattr2(int bufnum, attr_t newmode)
short fg, bg;
if (pair_content(pairnum, &fg, &bg) == OK)
- (void) sprintf(tmp,
- "{%d = {%s, %s}}",
- pairnum,
- COLOR_OF(fg),
- COLOR_OF(bg)
+ (void) snprintf(tmp, BUFSIZ - (tmp - buf),
+ "{%d = {%s, %s}}",
+ pairnum,
+ COLOR_OF(fg),
+ COLOR_OF(bg)
);
else
- (void) sprintf(tmp, "{%d}", pairnum);
+ (void) snprintf(tmp, BUFSIZ - (tmp - buf), "{%d}", pairnum);
}
}
}
@@ -212,7 +212,7 @@ _tracechtype2(int bufnum, chtype ch)
(void) strcat(buf, _tracechar(TextOf(ch)));
if (AttrOf(ch) != A_NORMAL)
- (void) sprintf(buf + strlen(buf), " | %s",
+ (void) snprintf(buf + strlen(buf), BUFSIZ - strlen(buf), " | %s",
_traceattr2(bufnum + 20, AttrOf(ch)));
strcat(buf, "}");
diff --git a/lib/libcurses/trace/lib_tracechr.c b/lib/libcurses/trace/lib_tracechr.c
index 340ca67913b..f69a9c59a1f 100644
--- a/lib/libcurses/trace/lib_tracechr.c
+++ b/lib/libcurses/trace/lib_tracechr.c
@@ -43,7 +43,8 @@ NCURSES_EXPORT(char *)
_tracechar(const unsigned char ch)
{
static char crep[20];
- (void) sprintf(crep, "'%s' = 0x%02x", unctrl(ch), (unsigned) ch);
+ (void) snprintf(crep, sizeof(crep), "'%s' = 0x%02x", unctrl(ch),
+ (unsigned) ch);
return (crep);
}
#else
diff --git a/lib/libcurses/trace/lib_tracedmp.c b/lib/libcurses/trace/lib_tracedmp.c
index 4a709fea869..4e557d65974 100644
--- a/lib/libcurses/trace/lib_tracedmp.c
+++ b/lib/libcurses/trace/lib_tracedmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_tracedmp.c,v 1.2 2001/01/22 18:01:58 millert Exp $ */
+/* $OpenBSD: lib_tracedmp.c,v 1.3 2003/03/17 19:16:59 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -65,10 +65,10 @@ _tracedump(const char *name, WINDOW *win)
bool haveattrs, havecolors;
/* dump A_CHARTEXT part */
- (void) sprintf(buf, "%s[%2d] %3d%3d ='",
- name, n,
- win->_line[n].firstchar,
- win->_line[n].lastchar);
+ (void) snprintf(buf, sizeof(buf), "%s[%2d] %3d%3d ='",
+ name, n,
+ win->_line[n].firstchar,
+ win->_line[n].lastchar);
ep = buf + strlen(buf);
for (j = 0; j <= width; j++) {
ep[j] = TextOf(win->_line[n].text[j]);
@@ -87,8 +87,8 @@ _tracedump(const char *name, WINDOW *win)
break;
}
if (havecolors) {
- (void) sprintf(buf, "%*s[%2d]%*s='", (int) strlen(name),
- "colors", n, 8, " ");
+ (void) snprintf(buf, sizeof(buf), "%*s[%2d]%*s='",
+ (int) strlen(name), "colors", n, 8, " ");
ep = buf + strlen(buf);
for (j = 0; j <= width; j++)
ep[j] = CharOf(win->_line[n].text[j] >> 8) + ' ';
@@ -108,8 +108,8 @@ _tracedump(const char *name, WINDOW *win)
break;
}
if (haveattrs) {
- (void) sprintf(buf, "%*s%d[%2d]%*s='", (int) strlen(name) -
- 1, "attrs", i, n, 8, " ");
+ (void) snprintf(buf, sizeof(buf), "%*s%d[%2d]%*s='",
+ (int) strlen(name) - 1, "attrs", i, n, 8, " ");
ep = buf + strlen(buf);
for (j = 0; j <= width; j++)
ep[j] = hex[(win->_line[n].text[j] & mask) >> ((i + 4) * 4)];
diff --git a/lib/libcurses/trace/lib_tracemse.c b/lib/libcurses/trace/lib_tracemse.c
index c92e4821eb0..fe0555eb07f 100644
--- a/lib/libcurses/trace/lib_tracemse.c
+++ b/lib/libcurses/trace/lib_tracemse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_tracemse.c,v 1.2 2001/01/22 18:01:58 millert Exp $ */
+/* $OpenBSD: lib_tracemse.c,v 1.3 2003/03/17 19:16:59 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -48,8 +48,8 @@ _tracemouse(MEVENT const *ep)
{
static char buf[80];
- (void) sprintf(buf, "id %2d at (%2d, %2d, %2d) state %4lx = {",
- ep->id, ep->x, ep->y, ep->z, ep->bstate);
+ (void) snprintf(buf, sizeof(buf), "id %2d at (%2d, %2d, %2d) state %4lx = {",
+ ep->id, ep->x, ep->y, ep->z, ep->bstate);
#define SHOW(m, s) if ((ep->bstate & m)==m) {strcat(buf,s); strcat(buf, ", ");}
SHOW(BUTTON1_RELEASED, "release-1")