diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-04-08 19:08:59 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-04-08 19:08:59 +0000 |
commit | c436910d4ee2059dd64af412e3dac7321ead2b00 (patch) | |
tree | d5437188a72d9da4765a80b247fefb9ea593fdad /usr.bin | |
parent | 8378839d332ad1c77b6d991f2701297f17d3407d (diff) |
string cleanup; ok tdeval
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/infocmp/infocmp.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/infocmp/infocmp.c b/usr.bin/infocmp/infocmp.c index 0e0c158235f..12b5bca3628 100644 --- a/usr.bin/infocmp/infocmp.c +++ b/usr.bin/infocmp/infocmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: infocmp.c,v 1.16 2003/04/06 18:41:03 deraadt Exp $ */ +/* $OpenBSD: infocmp.c,v 1.17 2003/04/08 19:08:58 deraadt Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -687,7 +687,8 @@ analyze_string(const char *name, const char *cap, TERMTYPE * tp) /* now look at the expansion we got, if any */ if (expansion) { - (void) sprintf(buf + strlen(buf), "{%s}", expansion); + (void) snprintf(buf + strlen(buf), sizeof buf - strlen(buf), + "{%s}", expansion); sp += len - 1; continue; } else { @@ -1039,7 +1040,7 @@ dump_initializers(TERMTYPE * term) && *sp != '"') *tp++ = *sp; else { - (void) sprintf(tp, "\\%03o", CharOf(*sp)); + (void) snprintf(tp, buf + sizeof buf - tp, "\\%03o", CharOf(*sp)); tp += 4; } } @@ -1123,7 +1124,8 @@ main(int argc, char *argv[]) char *terminal, *firstdir, *restdir; /* Avoid "local data >32k" error with mwcc */ /* Also avoid overflowing smaller stacks on systems like AmigaOS */ - path *tfile = (path *) malloc(sizeof(path) * MAXTERMS); + size_t tlen = sizeof(path) * MAXTERMS; + path *tfile = (path *) malloc(tlen); int c, i, len; bool formatted = FALSE; bool filecompare = FALSE; @@ -1317,7 +1319,9 @@ main(int argc, char *argv[]) tname[termcount] = argv[optind]; if (directory) { - (void) sprintf(tfile[termcount], "%s/%c/%s", + (void) snprintf(tfile[termcount], + tlen - termcount, + "%s/%c/%s", directory, *argv[optind], argv[optind]); if (itrace) |