summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-03-16 03:16:46 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-03-16 03:16:46 +0000
commit80a5f49083aba7ea1d732be0ac0e483459366a8b (patch)
tree15baeeec8e4f180e4908c0202dcea00c1d47ee1b
parent7be6df901996d2f8252b4b4c79a66406265d2d2e (diff)
more avoidance of snprintf, strcpy, and strcat; millert ok
-rw-r--r--lib/libcompat/4.3/rexec.c2
-rw-r--r--lib/libcompat/regexp/regexp.c17
2 files changed, 8 insertions, 11 deletions
diff --git a/lib/libcompat/4.3/rexec.c b/lib/libcompat/4.3/rexec.c
index 1f1413f3a7a..582ffb766fe 100644
--- a/lib/libcompat/4.3/rexec.c
+++ b/lib/libcompat/4.3/rexec.c
@@ -112,7 +112,7 @@ retry:
goto bad;
}
port = ntohs((u_short)sin2.sin_port);
- (void) sprintf(num, "%u", port);
+ (void) snprintf(num, sizeof num, "%u", port);
(void) write(s, num, strlen(num)+1);
{ int len = sizeof (from);
s3 = accept(s2, (struct sockaddr *)&from, &len);
diff --git a/lib/libcompat/regexp/regexp.c b/lib/libcompat/regexp/regexp.c
index e473c53a9d3..b1e3b965248 100644
--- a/lib/libcompat/regexp/regexp.c
+++ b/lib/libcompat/regexp/regexp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: regexp.c,v 1.3 2002/02/16 21:27:26 millert Exp $ */
+/* $OpenBSD: regexp.c,v 1.4 2003/03/16 03:16:45 deraadt Exp $ */
/*
* regcomp and regexec -- regsub and regerror are elsewhere
@@ -36,7 +36,7 @@
*/
#ifndef lint
-static char *rcsid = "$OpenBSD: regexp.c,v 1.3 2002/02/16 21:27:26 millert Exp $";
+static char *rcsid = "$OpenBSD: regexp.c,v 1.4 2003/03/16 03:16:45 deraadt Exp $";
#endif /* not lint */
#include <regexp.h>
@@ -1208,11 +1208,9 @@ static char *
regprop(op)
char *op;
{
- register char *p;
+ register char *p = NULL;
static char buf[50];
- (void) strcpy(buf, ":");
-
switch (OP(op)) {
case BOL:
p = "BOL";
@@ -1253,8 +1251,7 @@ char *op;
case OPEN+7:
case OPEN+8:
case OPEN+9:
- sprintf(buf+strlen(buf), "OPEN%d", OP(op)-OPEN);
- p = NULL;
+ snprintf(buf, sizeof buf, ":OPEN%d", OP(op)-OPEN);
break;
case CLOSE+1:
case CLOSE+2:
@@ -1265,8 +1262,7 @@ char *op;
case CLOSE+7:
case CLOSE+8:
case CLOSE+9:
- sprintf(buf+strlen(buf), "CLOSE%d", OP(op)-CLOSE);
- p = NULL;
+ snprintf(buf, sizeof buf, ":CLOSE%d", OP(op)-CLOSE);
break;
case STAR:
p = "STAR";
@@ -1282,10 +1278,11 @@ char *op;
break;
default:
v8_regerror("corrupted opcode");
+ p = "ERROR";
break;
}
if (p != NULL)
- (void) strcat(buf, p);
+ (void) snprintf(buf, sizeof buf, ":%s", p);
return(buf);
}
#endif