diff options
author | Daniel Hartmeier <dhartmei@cvs.openbsd.org> | 2003-01-09 18:55:33 +0000 |
---|---|---|
committer | Daniel Hartmeier <dhartmei@cvs.openbsd.org> | 2003-01-09 18:55:33 +0000 |
commit | 02562e4faa46e538bcb449c89640907c01a4e2c2 (patch) | |
tree | ba6e6c2fc99f4f671cb07b8b0064b0cf8cd84f9f /sbin | |
parent | 92e82c6f8c3d58a98d4ecc578abbbdee7c50a395 (diff) |
strlcpy return checks.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/pfctl/pfctl.c | 9 | ||||
-rw-r--r-- | sbin/pfctl/pfctl_altq.c | 10 | ||||
-rw-r--r-- | sbin/pfctl/pfctl_table.c | 18 |
3 files changed, 25 insertions, 12 deletions
diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index eac96cb1408..50b3689dfd2 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl.c,v 1.128 2003/01/09 18:34:29 henning Exp $ */ +/* $OpenBSD: pfctl.c,v 1.129 2003/01/09 18:55:32 dhartmei Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -1096,8 +1096,11 @@ pfctl_set_logif(struct pfctl *pf, char *ifname) if ((pf->opts & PF_OPT_NOACTION) == 0) { if (!strcmp(ifname, "none")) bzero(pi.ifname, sizeof(pi.ifname)); - else - strlcpy(pi.ifname, ifname, sizeof(pi.ifname)); + else { + if (strlcpy(pi.ifname, ifname, + sizeof(pi.ifname)) >= sizeof(pi.ifname)) + errx(1, "pfctl_set_logif: strlcpy"); + } if (ioctl(pf->dev, DIOCSETSTATUSIF, &pi)) return (1); } diff --git a/sbin/pfctl/pfctl_altq.c b/sbin/pfctl/pfctl_altq.c index c31af54f90c..24341ea7af8 100644 --- a/sbin/pfctl/pfctl_altq.c +++ b/sbin/pfctl/pfctl_altq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_altq.c,v 1.31 2003/01/09 17:33:19 henning Exp $ */ +/* $OpenBSD: pfctl_altq.c,v 1.32 2003/01/09 18:55:32 dhartmei Exp $ */ /* * Copyright (C) 2002 @@ -1043,7 +1043,9 @@ getifspeed(char *ifname) if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) err(1, "socket"); - strlcpy(ifr.ifr_name, ifname, IFNAMSIZ); + if (strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)) >= + sizeof(ifr.ifr_name)) + errx(1, "getifspeed: strlcpy"); ifr.ifr_data = (caddr_t)&ifrdat; if (ioctl(s, SIOCGIFDATA, (caddr_t)&ifr) == -1) err(1, "SIOCGIFDATA"); @@ -1060,7 +1062,9 @@ getifmtu(char *ifname) if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) err(1, "socket"); - strlcpy(ifr.ifr_name, ifname, IFNAMSIZ); + if (strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)) >= + sizeof(ifr.ifr_name)) + errx(1, "getifmtu: strlcpy"); if (ioctl(s, SIOCGIFMTU, (caddr_t)&ifr) == -1) err(1, "SIOCGIFMTU"); if (shutdown(s, SHUT_RDWR) == -1) diff --git a/sbin/pfctl/pfctl_table.c b/sbin/pfctl/pfctl_table.c index 9100aab7c6b..e879a5664df 100644 --- a/sbin/pfctl/pfctl_table.c +++ b/sbin/pfctl/pfctl_table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_table.c,v 1.13 2003/01/09 10:40:44 cedric Exp $ */ +/* $OpenBSD: pfctl_table.c,v 1.14 2003/01/09 18:55:32 dhartmei Exp $ */ /* * Copyright (c) 2002 Cedric Berger @@ -152,7 +152,9 @@ pfctl_table(int argc, char *argv[], char *tname, char *command, if (tname != NULL) { if (strlen(tname) >= PF_TABLE_NAME_SIZE) usage(); - strlcpy(table.pfrt_name, tname, PF_TABLE_NAME_SIZE); + if (strlcpy(table.pfrt_name, tname, + sizeof(table.pfrt_name)) >= sizeof(table.pfrt_name)) + errx(1, "pfctl_table: strlcpy"); } if (!strcmp(*p, "-F")) { if (argc || file != NULL) @@ -475,7 +477,8 @@ append_addr(char *s, int test) __progname, (long)strlen(s)); exit(1); } - strlcpy(buf, s+not, sizeof(buf)); + if (strlcpy(buf, s+not, sizeof(buf)) >= sizeof(buf)) + errx(1, "append_addr: strlcpy"); p = strrchr(buf, '/'); if (test && (not || p)) fprintf(stderr, "%s: illegal test address: \"%s\"\n", @@ -546,7 +549,8 @@ print_addrx(struct pfr_addr *ad, struct pfr_addr *rad, int dns) if (ad->pfra_net < hostnet) printf("/%d", ad->pfra_net); if (rad != NULL && fback != PFR_FB_NONE) { - strlcpy(buf, "{error}", sizeof buf); + if (strlcpy(buf, "{error}", sizeof(buf)) >= sizeof(buf)) + errx(1, "print_addrx: strlcpy"); inet_ntop(rad->pfra_af, &rad->pfra_u, buf, sizeof(buf)); printf("\t%c%s", (rad->pfra_not?'!':' '), buf); if (rad->pfra_net < hostnet) @@ -559,7 +563,7 @@ print_addrx(struct pfr_addr *ad, struct pfr_addr *rad, int dns) union sockaddr_union sa; int rv; - bzero(&sa, sizeof sa); + bzero(&sa, sizeof(sa)); sa.sa.sa_len = (ad->pfra_af == AF_INET) ? sizeof(sa.sin) : sizeof(sa.sin6); sa.sa.sa_family = ad->pfra_af; @@ -650,7 +654,9 @@ void pfctl_define_table(char *name, int flags, int addrs) return; } bzero(&tbl, sizeof(tbl)); - strlcpy(tbl.pfrt_name, name, sizeof(tbl.pfrt_name)); + if (strlcpy(tbl.pfrt_name, name, sizeof(tbl.pfrt_name)) >= + sizeof(tbl.pfrt_name)) + errx(1, "pfctl_define_table"); tbl.pfrt_flags = flags; inactive = 1; |