From: reyk Date: Sun, 20 Apr 2014 16:07:10 +0000 (+0000) Subject: Just to be pedantic, fail if strlcpy managed to overflow the socket path. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=29430719896ea7aa3e7efb38e123180b7982b025;p=openbsd Just to be pedantic, fail if strlcpy managed to overflow the socket path. --- diff --git a/usr.sbin/relayd/agentx.c b/usr.sbin/relayd/agentx.c index e11cc612329..645ab66c1f4 100644 --- a/usr.sbin/relayd/agentx.c +++ b/usr.sbin/relayd/agentx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agentx.c,v 1.4 2014/04/20 10:46:20 reyk Exp $ */ +/* $OpenBSD: agentx.c,v 1.5 2014/04/20 16:07:10 reyk Exp $ */ /* * Copyright (c) 2013,2014 Bret Stephen Lambert * @@ -91,7 +91,9 @@ snmp_agentx_open(const char *path, char *descr, struct snmp_oid *oid) bzero(&sun, sizeof(sun)); sun.sun_family = AF_UNIX; - strlcpy(sun.sun_path, path, sizeof(sun.sun_path)); + if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >= + sizeof(sun.sun_path)) + goto fail; if (connect(s, (struct sockaddr *)&sun, sizeof(sun)) == -1) goto fail; diff --git a/usr.sbin/snmpd/agentx.c b/usr.sbin/snmpd/agentx.c index e11cc612329..645ab66c1f4 100644 --- a/usr.sbin/snmpd/agentx.c +++ b/usr.sbin/snmpd/agentx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agentx.c,v 1.4 2014/04/20 10:46:20 reyk Exp $ */ +/* $OpenBSD: agentx.c,v 1.5 2014/04/20 16:07:10 reyk Exp $ */ /* * Copyright (c) 2013,2014 Bret Stephen Lambert * @@ -91,7 +91,9 @@ snmp_agentx_open(const char *path, char *descr, struct snmp_oid *oid) bzero(&sun, sizeof(sun)); sun.sun_family = AF_UNIX; - strlcpy(sun.sun_path, path, sizeof(sun.sun_path)); + if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >= + sizeof(sun.sun_path)) + goto fail; if (connect(s, (struct sockaddr *)&sun, sizeof(sun)) == -1) goto fail;