diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcurses/base/version.c | 2 | ||||
-rw-r--r-- | lib/libcurses/tinfo/captoinfo.c | 6 | ||||
-rw-r--r-- | lib/libcurses/tinfo/comp_expand.c | 8 | ||||
-rw-r--r-- | lib/libcurses/tinfo/comp_hash.c | 10 | ||||
-rw-r--r-- | lib/libcurses/tinfo/home_terminfo.c | 4 | ||||
-rw-r--r-- | lib/libcurses/tinfo/lib_tgoto.c | 4 | ||||
-rw-r--r-- | lib/libcurses/tinfo/lib_tparm.c | 6 | ||||
-rw-r--r-- | lib/libcurses/tinfo/lib_tputs.c | 4 | ||||
-rw-r--r-- | lib/libcurses/tinfo/parse_entry.c | 14 | ||||
-rw-r--r-- | lib/libcurses/tinfo/read_entry.c | 6 | ||||
-rw-r--r-- | lib/libcurses/tinfo/read_termcap.c | 5 | ||||
-rw-r--r-- | lib/libcurses/tinfo/write_entry.c | 8 | ||||
-rw-r--r-- | lib/libcurses/trace/lib_trace.c | 10 | ||||
-rw-r--r-- | lib/libcurses/trace/lib_traceatr.c | 16 | ||||
-rw-r--r-- | lib/libcurses/trace/lib_tracechr.c | 3 | ||||
-rw-r--r-- | lib/libcurses/trace/lib_tracedmp.c | 18 | ||||
-rw-r--r-- | lib/libcurses/trace/lib_tracemse.c | 6 | ||||
-rw-r--r-- | lib/libcurses/tty/hardscroll.c | 5 |
18 files changed, 70 insertions, 65 deletions
diff --git a/lib/libcurses/base/version.c b/lib/libcurses/base/version.c index d404e11d6ed..99cd40934e4 100644 --- a/lib/libcurses/base/version.c +++ b/lib/libcurses/base/version.c @@ -40,7 +40,7 @@ curses_version(void) static char my_version[80]; T((T_CALLED("curses_version()"))); - sprintf(my_version, "ncurses %s.%d", + snprintf(my_version, sizeof(my_version), "ncurses %s.%d", NCURSES_VERSION, NCURSES_VERSION_PATCH); returnPtr(my_version); diff --git a/lib/libcurses/tinfo/captoinfo.c b/lib/libcurses/tinfo/captoinfo.c index c36f7160660..6688647771c 100644 --- a/lib/libcurses/tinfo/captoinfo.c +++ b/lib/libcurses/tinfo/captoinfo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: captoinfo.c,v 1.9 2001/01/22 18:01:50 millert Exp $ */ +/* $OpenBSD: captoinfo.c,v 1.10 2003/03/17 19:16:59 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -579,7 +579,7 @@ bcd_expression(const char *str) { char buffer[80]; int tst; - sprintf(buffer, fmt, ch1, ch2); + snprintf(buffer, sizeof(buffer), fmt, ch1, ch2); tst = strlen(buffer) - 1; assert(len == tst); } @@ -601,7 +601,7 @@ save_tc_char(char *bufptr, int c1) if (c1 == (c1 & 0x1f)) /* iscntrl() returns T on 255 */ (void) strcpy(temp, unctrl((chtype) c1)); else - (void) sprintf(temp, "\\%03o", c1); + (void) snprintf(temp, sizeof(temp), "\\%03o", c1); bufptr = save_string(bufptr, temp); } return bufptr; diff --git a/lib/libcurses/tinfo/comp_expand.c b/lib/libcurses/tinfo/comp_expand.c index 3de650bd120..0d47e83da6a 100644 --- a/lib/libcurses/tinfo/comp_expand.c +++ b/lib/libcurses/tinfo/comp_expand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: comp_expand.c,v 1.4 2001/01/22 18:01:51 millert Exp $ */ +/* $OpenBSD: comp_expand.c,v 1.5 2003/03/17 19:16:59 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,2000 Free Software Foundation, Inc. * @@ -85,7 +85,7 @@ _nc_tic_expand && str[1] != '\\' && REALPRINT(str + 1) && str[2] == S_QUOTE) { - sprintf(buffer + bufp, "{%d}", str[1]); + snprintf(buffer + bufp, length - bufp, "{%d}", str[1]); bufp += strlen(buffer + bufp); str += 2; } else { @@ -172,10 +172,10 @@ _nc_tic_expand #define UnCtl(c) ((c) + '@') else if (REALCTL(str) && ch != '\\' && (!islong || isdigit(CharOf(str[1])))) { - (void) sprintf(&buffer[bufp], "^%c", UnCtl(ch)); + (void) snprintf(buffer + bufp, length - bufp, "^%c", UnCtl(ch)); bufp += 2; } else { - (void) sprintf(&buffer[bufp], "\\%03o", ch); + (void) snprintf(buffer + bufp, length - bufp, "\\%03o", ch); bufp += 4; } diff --git a/lib/libcurses/tinfo/comp_hash.c b/lib/libcurses/tinfo/comp_hash.c index be52efa37ab..6a21fbbf505 100644 --- a/lib/libcurses/tinfo/comp_hash.c +++ b/lib/libcurses/tinfo/comp_hash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: comp_hash.c,v 1.4 1999/06/27 08:14:21 millert Exp $ */ +/* $OpenBSD: comp_hash.c,v 1.5 2003/03/17 19:16:59 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -288,8 +288,8 @@ int main(int argc, char **argv) root_name); printf("{\n"); for (n = 0; n < CAPTABSIZE; n++) { - sprintf(buffer, "\"%s\"", - name_table[n].nte_name); + snprintf(buffer, sizeof(buffer), "\"%s\"", + name_table[n].nte_name); printf("\t{ %15s,\t%10s,\t%3d, %3d }%c\n", buffer, typenames[name_table[n].nte_type], @@ -305,8 +305,8 @@ int main(int argc, char **argv) printf("{\n"); for (n = 0; n < HASHTABSIZE; n++) { if (hash_table[n] != 0) { - sprintf(buffer, "_nc_%s_table + %3ld", - root_name, + snprintf(buffer, sizeof(buffer), "_nc_%s_table + %3ld", + root_name, (long) (hash_table[n] - name_table)); } else { strcpy(buffer, "0"); diff --git a/lib/libcurses/tinfo/home_terminfo.c b/lib/libcurses/tinfo/home_terminfo.c index 13b0cad7e6c..955955484fc 100644 --- a/lib/libcurses/tinfo/home_terminfo.c +++ b/lib/libcurses/tinfo/home_terminfo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: home_terminfo.c,v 1.7 2001/01/22 18:01:51 millert Exp $ */ +/* $OpenBSD: home_terminfo.c,v 1.8 2003/03/17 19:16:59 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,2000 Free Software Foundation, Inc. * @@ -58,7 +58,7 @@ _nc_home_terminfo(void) temp = typeMalloc(char, my_length); if (temp == 0) _nc_err_abort("Out of memory"); - (void) sprintf(temp, PRIVATE_INFO, home); + (void) snprintf(temp, my_length, PRIVATE_INFO, home); } } return temp; diff --git a/lib/libcurses/tinfo/lib_tgoto.c b/lib/libcurses/tinfo/lib_tgoto.c index c54cb39443c..b3f9f86ab45 100644 --- a/lib/libcurses/tinfo/lib_tgoto.c +++ b/lib/libcurses/tinfo/lib_tgoto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_tgoto.c,v 1.2 2001/01/22 18:01:53 millert Exp $ */ +/* $OpenBSD: lib_tgoto.c,v 1.3 2003/03/17 19:16:59 millert Exp $ */ /**************************************************************************** * Copyright (c) 2000 Free Software Foundation, Inc. * @@ -161,7 +161,7 @@ tgoto_internal(const char *string, int x, int y) break; } if (fmt != 0) { - sprintf(result + used, fmt, *value++); + snprintf(result + used, length - used, fmt, *value++); used += strlen(result + used); fmt = 0; } diff --git a/lib/libcurses/tinfo/lib_tparm.c b/lib/libcurses/tinfo/lib_tparm.c index e5c496dd1c3..3cdd7b915fc 100644 --- a/lib/libcurses/tinfo/lib_tparm.c +++ b/lib/libcurses/tinfo/lib_tparm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_tparm.c,v 1.7 2001/01/22 18:01:54 millert Exp $ */ +/* $OpenBSD: lib_tparm.c,v 1.8 2003/03/17 19:16:59 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,2000 Free Software Foundation, Inc. * @@ -165,7 +165,7 @@ save_text(const char *fmt, const char *s, int len) get_space(s_len + 1); - (void) sprintf(out_buff + out_used, fmt, s); + (void) snprintf(out_buff + out_used, out_size - out_used, fmt, s); out_used += strlen(out_buff + out_used); } @@ -177,7 +177,7 @@ save_number(const char *fmt, int number, int len) get_space(len + 1); - (void) sprintf(out_buff + out_used, fmt, number); + (void) snprintf(out_buff + out_used, out_size - out_used, fmt, number); out_used += strlen(out_buff + out_used); } diff --git a/lib/libcurses/tinfo/lib_tputs.c b/lib/libcurses/tinfo/lib_tputs.c index fb20e9dc782..046dc70c512 100644 --- a/lib/libcurses/tinfo/lib_tputs.c +++ b/lib/libcurses/tinfo/lib_tputs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_tputs.c,v 1.9 2001/01/22 18:01:54 millert Exp $ */ +/* $OpenBSD: lib_tputs.c,v 1.10 2003/03/17 19:16:59 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -196,7 +196,7 @@ tputs if (outc == _nc_outch) (void) strcpy(addrbuf, "_nc_outch"); else - (void) sprintf(addrbuf, "%p", outc); + (void) snprintf(addrbuf, sizeof(addrbuf), "%p", outc); if (_nc_tputs_trace) { _tracef("tputs(%s = %s, %d, %s) called", _nc_tputs_trace, _nc_visbuf(string), affcnt, addrbuf); diff --git a/lib/libcurses/tinfo/parse_entry.c b/lib/libcurses/tinfo/parse_entry.c index 5d077f242b1..4a42654d670 100644 --- a/lib/libcurses/tinfo/parse_entry.c +++ b/lib/libcurses/tinfo/parse_entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse_entry.c,v 1.11 2003/03/10 04:02:49 david Exp $ */ +/* $OpenBSD: parse_entry.c,v 1.12 2003/03/17 19:16:59 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -619,14 +619,14 @@ postprocess_termcap(TERMTYPE * tp, bool has_base) if (WANTED(carriage_return)) { if (carriage_return_delay > 0) { - sprintf(buf, "%s$<%d>", C_CR, carriage_return_delay); + snprintf(buf, sizeof(buf), "%s$<%d>", C_CR, carriage_return_delay); carriage_return = _nc_save_str(buf); } else carriage_return = _nc_save_str(C_CR); } if (WANTED(cursor_left)) { if (backspace_delay > 0) { - sprintf(buf, "%s$<%d>", C_BS, backspace_delay); + snprintf(buf, sizeof(buf), "%s$<%d>", C_BS, backspace_delay); cursor_left = _nc_save_str(buf); } else if (backspaces_with_bs == 1) cursor_left = _nc_save_str(C_BS); @@ -639,7 +639,7 @@ postprocess_termcap(TERMTYPE * tp, bool has_base) cursor_down = linefeed_if_not_lf; else if (linefeed_is_newline != 1) { if (new_line_delay > 0) { - sprintf(buf, "%s$<%d>", C_LF, new_line_delay); + snprintf(buf, sizeof(buf), "%s$<%d>", C_LF, new_line_delay); cursor_down = _nc_save_str(buf); } else cursor_down = _nc_save_str(C_LF); @@ -650,7 +650,7 @@ postprocess_termcap(TERMTYPE * tp, bool has_base) cursor_down = linefeed_if_not_lf; else if (linefeed_is_newline != 1) { if (new_line_delay > 0) { - sprintf(buf, "%s$<%d>", C_LF, new_line_delay); + snprintf(buf, sizeof(buf), "%s$<%d>", C_LF, new_line_delay); scroll_forward = _nc_save_str(buf); } else scroll_forward = _nc_save_str(C_LF); @@ -659,7 +659,7 @@ postprocess_termcap(TERMTYPE * tp, bool has_base) if (WANTED(newline)) { if (linefeed_is_newline == 1) { if (new_line_delay > 0) { - sprintf(buf, "%s$<%d>", C_LF, new_line_delay); + snprintf(buf, sizeof(buf), "%s$<%d>", C_LF, new_line_delay); newline = _nc_save_str(buf); } else newline = _nc_save_str(C_LF); @@ -701,7 +701,7 @@ postprocess_termcap(TERMTYPE * tp, bool has_base) */ if (WANTED(tab)) { if (horizontal_tab_delay > 0) { - sprintf(buf, "%s$<%d>", C_HT, horizontal_tab_delay); + snprintf(buf, sizeof(buf), "%s$<%d>", C_HT, horizontal_tab_delay); tab = _nc_save_str(buf); } else tab = _nc_save_str(C_HT); diff --git a/lib/libcurses/tinfo/read_entry.c b/lib/libcurses/tinfo/read_entry.c index 2d6f4ba4ba6..8c31ca39dd3 100644 --- a/lib/libcurses/tinfo/read_entry.c +++ b/lib/libcurses/tinfo/read_entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read_entry.c,v 1.12 2001/01/22 18:01:55 millert Exp $ */ +/* $OpenBSD: read_entry.c,v 1.13 2003/03/17 19:16:59 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -414,7 +414,7 @@ _nc_read_tic_entry(char *const filename, if (strlen(dir) > MAX_TPATH) return 0; - (void) sprintf(filename, "%s/%s", dir, ttn); + (void) snprintf(filename, MAX_TPATH + 1, "%s/%s", dir, ttn); return _nc_read_file_entry(filename, tp); } @@ -478,7 +478,7 @@ _nc_read_entry #endif /* __OpenBSD__ */ /* truncate the terminal name to prevent dangerous buffer airline */ - (void) sprintf(ttn, "%c/%.*s", *tn, MAX_ALIAS, tn); + (void) snprintf(ttn, sizeof(ttn), "%c/%.*s", *tn, MAX_ALIAS, tn); /* This is System V behavior, in conjunction with our requirements for * writing terminfo entries. diff --git a/lib/libcurses/tinfo/read_termcap.c b/lib/libcurses/tinfo/read_termcap.c index 16a4df5a99e..0460854889f 100644 --- a/lib/libcurses/tinfo/read_termcap.c +++ b/lib/libcurses/tinfo/read_termcap.c @@ -985,7 +985,8 @@ _nc_read_termcap_entry ADD_TC(tc, 0); } else if (_nc_name_match(tc, tn, "|:")) { /* treat as a capability file */ use_buffer = TRUE; - (void) sprintf(tc_buf, "%.*s\n", (int) sizeof(tc_buf) - 2, tc); + (void) snprintf(tc_buf, sizeof(tc_buf), "%.*s\n", + (int) sizeof(tc_buf) - 2, tc); } else if ((tc = getenv("TERMPATH")) != 0) { char *cp; @@ -1017,7 +1018,7 @@ _nc_read_termcap_entry && (strlen(h) + sizeof(PRIVATE_CAP)) < PATH_MAX) { /* user's .termcap, if any, should override it */ (void) strcpy(envhome, h); - (void) sprintf(pathbuf, PRIVATE_CAP, envhome); + (void) snprintf(pathbuf, sizeof(pathbuf), PRIVATE_CAP, envhome); ADD_TC(pathbuf, filecount); } } diff --git a/lib/libcurses/tinfo/write_entry.c b/lib/libcurses/tinfo/write_entry.c index c7a5958a4bf..97be60e8abe 100644 --- a/lib/libcurses/tinfo/write_entry.c +++ b/lib/libcurses/tinfo/write_entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: write_entry.c,v 1.10 2001/01/22 18:01:57 millert Exp $ */ +/* $OpenBSD: write_entry.c,v 1.11 2003/03/17 19:16:59 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -96,7 +96,7 @@ make_directory(const char *path) } else { if (strlen(destination) + strlen(path) + 2 > sizeof(fullpath)) return (-1); - (void) sprintf(fullpath, "%s/%s", destination, path); + (void) snprintf(fullpath, sizeof(fullpath), "%s/%s", destination, path); } if ((rc = stat(path, &statbuf)) < 0) { @@ -257,7 +257,7 @@ _nc_write_entry(TERMTYPE * const tp) if (strlen(first_name) > sizeof(filename) - 3) _nc_warning("terminal name too long."); - sprintf(filename, "%c/%s", first_name[0], first_name); + snprintf(filename, sizeof(filename), "%c/%s", first_name[0], first_name); /* * Has this primary name been written since the first call to @@ -298,7 +298,7 @@ _nc_write_entry(TERMTYPE * const tp) } check_writeable(ptr[0]); - sprintf(linkname, "%c/%s", ptr[0], ptr); + snprintf(linkname, sizeof(linkname), "%c/%s", ptr[0], ptr); if (strcmp(filename, linkname) == 0) { _nc_warning("self-synonym ignored"); 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") diff --git a/lib/libcurses/tty/hardscroll.c b/lib/libcurses/tty/hardscroll.c index c143201465e..92dc08ebe6d 100644 --- a/lib/libcurses/tty/hardscroll.c +++ b/lib/libcurses/tty/hardscroll.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hardscroll.c,v 1.4 2002/06/22 18:13:05 deraadt Exp $ */ +/* $OpenBSD: hardscroll.c,v 1.5 2003/03/17 19:16:59 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,2000 Free Software Foundation, Inc. * @@ -273,7 +273,8 @@ _nc_linedump(void) (void) strcpy(buf, "virt"); for (n = 0; n < screen_lines; n++) - (void) sprintf(buf + strlen(buf), " %02d", OLDNUM(n)); + (void) snprintf(buf + strlen(buf), have - strlen(buf), " %02d", + OLDNUM(n)); TR(TRACE_UPDATE | TRACE_MOVE, (buf)); #if NO_LEAKS free(buf); |