diff options
-rw-r--r-- | usr.bin/tn3270/api/api_exch.c | 8 | ||||
-rw-r--r-- | usr.bin/tn3270/ascii/map3270.c | 15 | ||||
-rw-r--r-- | usr.bin/tn3270/ascii/mset.c | 6 | ||||
-rw-r--r-- | usr.bin/tn3270/ctlr/inbound.c | 9 | ||||
-rw-r--r-- | usr.bin/tn3270/ctlr/outbound.c | 16 | ||||
-rw-r--r-- | usr.bin/tn3270/sys_curses/system.c | 13 | ||||
-rw-r--r-- | usr.bin/tn3270/sys_curses/termout.c | 6 | ||||
-rw-r--r-- | usr.bin/tn3270/tools/mkhits/dohits.c | 8 | ||||
-rw-r--r-- | usr.bin/tn3270/tools/prt3270.c | 10 |
9 files changed, 43 insertions, 48 deletions
diff --git a/usr.bin/tn3270/api/api_exch.c b/usr.bin/tn3270/api/api_exch.c index 74bd8e21b1f..7fb3d5f7a4d 100644 --- a/usr.bin/tn3270/api/api_exch.c +++ b/usr.bin/tn3270/api/api_exch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: api_exch.c,v 1.2 1996/06/26 05:41:00 deraadt Exp $ */ +/* $OpenBSD: api_exch.c,v 1.3 2003/04/04 22:13:10 deraadt Exp $ */ /*- * Copyright (c) 1988 The Regents of the University of California. @@ -35,7 +35,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)api_exch.c 4.2 (Berkeley) 4/26/91";*/ -static char rcsid[] = "$OpenBSD: api_exch.c,v 1.2 1996/06/26 05:41:00 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: api_exch.c,v 1.3 2003/04/04 22:13:10 deraadt Exp $"; #endif /* not lint */ #include <stdio.h> @@ -153,7 +153,7 @@ int exch; /* opcode to decode */ { static char unknown[40]; - sprintf(unknown, "(Unknown exchange 0x%02x)", exch&0xff); + snprintf(unknown, sizeof unknown, "(Unknown exchange 0x%02x)", exch&0xff); return unknown; } } @@ -416,8 +416,6 @@ api_exch_init(sock_number, ourname) int sock_number; char *ourname; { - extern char *strcpy(); - sock = sock_number; (void) strcpy(whoarewe, ourname); /* For error messages */ diff --git a/usr.bin/tn3270/ascii/map3270.c b/usr.bin/tn3270/ascii/map3270.c index b4d48385a3a..eddbce18569 100644 --- a/usr.bin/tn3270/ascii/map3270.c +++ b/usr.bin/tn3270/ascii/map3270.c @@ -1,4 +1,4 @@ -/* $OpenBSD: map3270.c,v 1.4 2001/11/19 19:02:16 mpech Exp $ */ +/* $OpenBSD: map3270.c,v 1.5 2003/04/04 22:13:10 deraadt Exp $ */ /*- * Copyright (c) 1988 The Regents of the University of California. @@ -35,7 +35,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)map3270.c 4.2 (Berkeley) 4/26/91";*/ -static char rcsid[] = "$OpenBSD: map3270.c,v 1.4 2001/11/19 19:02:16 mpech Exp $"; +static char rcsid[] = "$OpenBSD: map3270.c,v 1.5 2003/04/04 22:13:10 deraadt Exp $"; #endif /* not lint */ /* This program reads a description file, somewhat like /etc/termcap, @@ -147,7 +147,7 @@ GetC() char envname[9]; extern char *getenv(); - (void) sprintf(envname, "MAP3270%c", suffix++); + (void) snprintf(envname, sizeof envname, "MAP3270%c", suffix++); environPointer = getenv(envname); } else { whichkey++; /* default map */ @@ -831,14 +831,7 @@ char * strsave(string) char *string; { - char *p; - extern char *malloc(); - - p = malloc((unsigned int)strlen(string)+1); - if (p != 0) { - strcpy(p, string); - } - return(p); + return (strdup(string)); } diff --git a/usr.bin/tn3270/ascii/mset.c b/usr.bin/tn3270/ascii/mset.c index de285c6fe11..e2c95c844a7 100644 --- a/usr.bin/tn3270/ascii/mset.c +++ b/usr.bin/tn3270/ascii/mset.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mset.c,v 1.3 2001/11/19 19:02:16 mpech Exp $ */ +/* $OpenBSD: mset.c,v 1.4 2003/04/04 22:13:10 deraadt Exp $ */ /*- * Copyright (c) 1988 The Regents of the University of California. @@ -41,7 +41,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)mset.c 4.2 (Berkeley) 4/26/91";*/ -static char rcsid[] = "$OpenBSD: mset.c,v 1.3 2001/11/19 19:02:16 mpech Exp $"; +static char rcsid[] = "$OpenBSD: mset.c,v 1.4 2003/04/04 22:13:10 deraadt Exp $"; #endif /* not lint */ /* @@ -221,7 +221,7 @@ char *begin, *tc_name; else { printf("'"); } - (void) strcpy(savename, tc_name); + (void) strlcpy(savename, tc_name, sizeof savename); while (st1 != string) { if (toshell && numbchars >= 1016) { /* leave room for ctrl and delim */ numbchars = 0; diff --git a/usr.bin/tn3270/ctlr/inbound.c b/usr.bin/tn3270/ctlr/inbound.c index f2d3863ef74..c2c3b7c072a 100644 --- a/usr.bin/tn3270/ctlr/inbound.c +++ b/usr.bin/tn3270/ctlr/inbound.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inbound.c,v 1.4 2001/11/19 19:02:17 mpech Exp $ */ +/* $OpenBSD: inbound.c,v 1.5 2003/04/04 22:13:10 deraadt Exp $ */ /*- * Copyright (c) 1988 The Regents of the University of California. @@ -35,7 +35,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)inbound.c 4.3 (Berkeley) 4/26/91";*/ -static char rcsid[] = "$OpenBSD: inbound.c,v 1.4 2001/11/19 19:02:17 mpech Exp $"; +static char rcsid[] = "$OpenBSD: inbound.c,v 1.5 2003/04/04 22:13:10 deraadt Exp $"; #endif /* not lint */ #include <stdio.h> @@ -373,8 +373,9 @@ char character; } else { char buffer[100]; - sprintf(buffer, "File %s, line %d: No room in network buffer!\n", - __FILE__, __LINE__); + snprintf(buffer, sizeof buffer, + "File %s, line %d: No room in network buffer!\n", + __FILE__, __LINE__); ExitString(buffer, 1); /*NOTREACHED*/ } diff --git a/usr.bin/tn3270/ctlr/outbound.c b/usr.bin/tn3270/ctlr/outbound.c index 5fcacba9f02..a801e0adb35 100644 --- a/usr.bin/tn3270/ctlr/outbound.c +++ b/usr.bin/tn3270/ctlr/outbound.c @@ -1,4 +1,4 @@ -/* $OpenBSD: outbound.c,v 1.3 2001/11/19 19:02:17 mpech Exp $ */ +/* $OpenBSD: outbound.c,v 1.4 2003/04/04 22:13:10 deraadt Exp $ */ /*- * Copyright (c) 1988 The Regents of the University of California. @@ -35,7 +35,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)outbound.c 4.3 (Berkeley) 4/26/91";*/ -static char rcsid[] = "$OpenBSD: outbound.c,v 1.3 2001/11/19 19:02:17 mpech Exp $"; +static char rcsid[] = "$OpenBSD: outbound.c,v 1.4 2003/04/04 22:13:10 deraadt Exp $"; #endif /* not lint */ #include <stdio.h> @@ -225,7 +225,7 @@ int control; /* this buffer ended block? */ { char s_buffer[100]; - sprintf(s_buffer, + snprintf(s_buffer, sizeof s_buffer, "Unexpected read command code 0x%x received.\n", Command); ExitString(s_buffer, 1); @@ -324,7 +324,7 @@ int control; /* this buffer ended block? */ { char s_buffer[100]; - sprintf(s_buffer, + snprintf(s_buffer, sizeof s_buffer, "Unexpected write command code 0x%x received.\n", Command); ExitString(s_buffer, 1); @@ -414,7 +414,8 @@ int control; /* this buffer ended block? */ if ((i < 0) || (i > HighestScreen())) { char s_buffer[200]; - sprintf(s_buffer, "tn3270: %s%d.\n\t%s%d%s%d%s\n", + snprintf(s_buffer, sizeof s_buffer, + "tn3270: %s%d.\n\t%s%d%s%d%s\n", "Invalid 3270 order 'Repeat to Address' to address ", i, "(Screen currently set to ", @@ -452,7 +453,8 @@ int control; /* this buffer ended block? */ if ((i < 0) || (i > HighestScreen())) { char s_buffer[200]; - sprintf(s_buffer, "tn3270: %s%d.\n\t%s%d%s%d%s\n", + snprintf(s_buffer, sizeof s_buffer, + "tn3270: %s%d.\n\t%s%d%s%d%s\n", "Invalid 3270 order 'Erase Unprotected to Address' to address ", i, "(Screen currently set to ", @@ -506,7 +508,7 @@ int control; /* this buffer ended block? */ break; } } - sprintf(s_buffer, + snprintf(s_buffer, sizeof s_buffer, "Unsupported order '%s' (%s, 0x%x) received.\n", porder->long_name, porder->short_name, c); ExitString(s_buffer, 1); diff --git a/usr.bin/tn3270/sys_curses/system.c b/usr.bin/tn3270/sys_curses/system.c index ddb9094b9c8..f7b6f2539d9 100644 --- a/usr.bin/tn3270/sys_curses/system.c +++ b/usr.bin/tn3270/sys_curses/system.c @@ -1,4 +1,4 @@ -/* $OpenBSD: system.c,v 1.11 2002/06/12 06:07:16 mpech Exp $ */ +/* $OpenBSD: system.c,v 1.12 2003/04/04 22:13:10 deraadt Exp $ */ /*- * Copyright (c) 1988 The Regents of the University of California. @@ -35,7 +35,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)system.c 4.5 (Berkeley) 4/26/91";*/ -static char rcsid[] = "$OpenBSD: system.c,v 1.11 2002/06/12 06:07:16 mpech Exp $"; +static char rcsid[] = "$OpenBSD: system.c,v 1.12 2003/04/04 22:13:10 deraadt Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -214,7 +214,8 @@ doassociate() if ((pwent = getpwuid((int)geteuid())) == 0) { return -1; } - sprintf(promptbuf, "Enter password for user %s:", pwent->pw_name); + snprintf(promptbuf, sizeof promptbuf, + "Enter password for user %s:", pwent->pw_name); if (api_exch_outcommand(EXCH_CMD_SEND_AUTH) == -1) { return -1; } @@ -658,7 +659,7 @@ char *argv[]; do { ikey = random(); } while (ikey == 0); - sprintf(key, "%lu\n", (unsigned long) ikey); + snprintf(key, sizeof key, "%lu\n", (unsigned long) ikey); if (write(fd, key, strlen(key)) != strlen(key)) { perror("write"); return 0; @@ -690,11 +691,11 @@ char *argv[]; } listen(serversock, 1); /* Get name to advertise in address list */ - strcpy(sockNAME, "API3270="); + strlcpy(sockNAME, "API3270=", sizeof sockNAME); gethostname(sockNAME+strlen(sockNAME), sizeof sockNAME-strlen(sockNAME)); if (strlen(sockNAME) > (sizeof sockNAME-(10+strlen(keyname)))) { fprintf(stderr, "Local hostname too large; using 'localhost'.\n"); - strcpy(sockNAME, "localhost"); + strlcpy(sockNAME, "localhost", sizeof sockNAME); } sprintf(sockNAME+strlen(sockNAME), ":%u", ntohs(server.sin_port)); sprintf(sockNAME+strlen(sockNAME), ":%s", keyname); diff --git a/usr.bin/tn3270/sys_curses/termout.c b/usr.bin/tn3270/sys_curses/termout.c index 3e0c4a52c68..252f8be5124 100644 --- a/usr.bin/tn3270/sys_curses/termout.c +++ b/usr.bin/tn3270/sys_curses/termout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: termout.c,v 1.8 2001/11/19 19:02:17 mpech Exp $ */ +/* $OpenBSD: termout.c,v 1.9 2003/04/04 22:13:10 deraadt Exp $ */ /*- * Copyright (c) 1988 The Regents of the University of California. @@ -35,7 +35,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)termout.c 4.3 (Berkeley) 4/26/91";*/ -static char rcsid[] = "$OpenBSD: termout.c,v 1.8 2001/11/19 19:02:17 mpech Exp $"; +static char rcsid[] = "$OpenBSD: termout.c,v 1.9 2003/04/04 22:13:10 deraadt Exp $"; #endif /* not lint */ #if defined(unix) @@ -156,7 +156,7 @@ int where; /* cursor address */ { char foo[100]; - sprintf(foo, "ERR from %s at %d (%d, %d)\n", + snprintf(foo, sizeof foo, "ERR from %s at %d (%d, %d)\n", from, where, ScreenLine(where), ScreenLineOffset(where)); OurExitString(foo, 1); /* NOTREACHED */ diff --git a/usr.bin/tn3270/tools/mkhits/dohits.c b/usr.bin/tn3270/tools/mkhits/dohits.c index e3dc7d05338..c4cfee4fa79 100644 --- a/usr.bin/tn3270/tools/mkhits/dohits.c +++ b/usr.bin/tn3270/tools/mkhits/dohits.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dohits.c,v 1.4 2001/11/19 19:02:17 mpech Exp $ */ +/* $OpenBSD: dohits.c,v 1.5 2003/04/04 22:13:10 deraadt Exp $ */ /*- * Copyright (c) 1988 The Regents of the University of California. @@ -35,7 +35,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)dohits.c 4.2 (Berkeley) 4/26/91";*/ -static char rcsid[] = "$OpenBSD: dohits.c,v 1.4 2001/11/19 19:02:17 mpech Exp $"; +static char rcsid[] = "$OpenBSD: dohits.c,v 1.5 2003/04/04 22:13:10 deraadt Exp $"; #endif /* not lint */ /* @@ -121,7 +121,7 @@ char *file, /* Name of file to scan for whitespace prefix */ char what[100], value[100]; char line[200]; - sprintf(compare, " %s%%[^,\t \n]", prefix); + snprintf(compare, sizeof compare, " %s%%[^,\t \n]", prefix); if ((ourfile = fopen(file, "r")) == NULL) { perror("fopen"); exit(1); @@ -152,7 +152,7 @@ char *file, /* Name of file to scan for #define prefix */ char line[200]; int whatitis; - sprintf(compare, "#define %s%%s %%s", prefix); + snprintf(compare, sizeof compare, "#define %s%%s %%s", prefix); if ((ourfile = fopen(file, "r")) == NULL) { perror("fopen"); exit(1); diff --git a/usr.bin/tn3270/tools/prt3270.c b/usr.bin/tn3270/tools/prt3270.c index 518f36f5f1b..37d6e4c196d 100644 --- a/usr.bin/tn3270/tools/prt3270.c +++ b/usr.bin/tn3270/tools/prt3270.c @@ -1,4 +1,4 @@ -/* $OpenBSD: prt3270.c,v 1.3 2001/11/19 19:02:17 mpech Exp $ */ +/* $OpenBSD: prt3270.c,v 1.4 2003/04/04 22:13:10 deraadt Exp $ */ /*- * Copyright (c) 1988 The Regents of the University of California. @@ -41,7 +41,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)prt3270.c 4.2 (Berkeley) 4/26/91";*/ -static char rcsid[] = "$OpenBSD: prt3270.c,v 1.3 2001/11/19 19:02:17 mpech Exp $"; +static char rcsid[] = "$OpenBSD: prt3270.c,v 1.4 2003/04/04 22:13:10 deraadt Exp $"; #endif /* not lint */ #if defined(unix) @@ -161,7 +161,7 @@ int i; { char place[40]; - sprintf(place, "%02x", i); + snprintf(place, sizeof place, "%02x", i); putstr(place); } @@ -172,7 +172,7 @@ int i; { char place[40]; - sprintf(place, "%d", i); + snprintf(place, sizeof place, "%d", i); putstr(place); } @@ -182,7 +182,7 @@ int i; { char place[40]; - sprintf(place, "%x", i); + snprintf(place, sizeof place, "%x", i); putstr(place); } |