summaryrefslogtreecommitdiffstats
path: root/usr.sbin/raycontrol
diff options
context:
space:
mode:
authorroam <roam@FreeBSD.org>2002-12-02 20:29:08 +0000
committerroam <roam@FreeBSD.org>2002-12-02 20:29:08 +0000
commita396a56831490577d914ea4c1d26aec5728b6cdc (patch)
tree734ba55f2e25943bc6d6682d6a6a8c480b70cd70 /usr.sbin/raycontrol
parentbf720d1bf7acd15326c5af3d2e3de21840d56cdf (diff)
downloadFreeBSD-src-a396a56831490577d914ea4c1d26aec5728b6cdc.zip
FreeBSD-src-a396a56831490577d914ea4c1d26aec5728b6cdc.tar.gz
Replace the remaining strcpy() instances with strlcpy(), fixing a segfault
when parsing a malformed command-line parameter. Rearrange a risky usage of sprintf() in a loop. Reported by: phrail@division7.us via the vuln-dev mailing list Approved by: re (rwatson)
Diffstat (limited to 'usr.sbin/raycontrol')
-rw-r--r--usr.sbin/raycontrol/raycontrol.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/usr.sbin/raycontrol/raycontrol.c b/usr.sbin/raycontrol/raycontrol.c
index e361c5d..c287643 100644
--- a/usr.sbin/raycontrol/raycontrol.c
+++ b/usr.sbin/raycontrol/raycontrol.c
@@ -75,14 +75,12 @@ ray_printhex(u_int8_t *d, char *s, int len)
char *p;
int i;
- if (len > 256)
+ if (2 * len + strlen(s) * (len - 1) > sizeof(buf) - 1)
err(1, "Byte string too long");
sprintf(buf, "%02x", *d);
- for (p = buf + 2, i = 1; i < len; i++) {
- sprintf(p, "%s%02x", s, *(d+i));
- p = p + 2 + strlen(s);
- }
+ for (p = buf + 2, i = 1; i < len; i++)
+ p += sprintf(p, "%s%02x", s, *(d+i));
return(buf);
}
@@ -118,7 +116,7 @@ ray_getsiglev(char *iface, struct ray_siglev *siglev)
bzero((char *)&ifr, sizeof(ifr));
- strcpy(ifr.ifr_name, iface);
+ strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name));
ifr.ifr_data = (caddr_t)siglev;
s = socket(AF_INET, SOCK_DGRAM, 0);
@@ -140,7 +138,7 @@ ray_getstats(char *iface, struct ray_stats_req *sreq)
bzero((char *)&ifr, sizeof(ifr));
- strcpy(ifr.ifr_name, iface);
+ strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name));
ifr.ifr_data = (caddr_t)sreq;
s = socket(AF_INET, SOCK_DGRAM, 0);
@@ -271,7 +269,7 @@ ray_setval(char *iface, struct ray_param_req *rreq)
bzero((char *)&ifr, sizeof(ifr));
- strcpy(ifr.ifr_name, iface);
+ strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name));
ifr.ifr_data = (caddr_t)rreq;
s = socket(AF_INET, SOCK_DGRAM, 0);
OpenPOWER on IntegriCloud