From: gilles Date: Sat, 19 Apr 2014 11:29:06 +0000 (+0000) Subject: when copying socket path, check that we didnt truncate it which would cause X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ffd15e3fde4e85aeafa22b4a67fca48c545bc70a;p=openbsd when copying socket path, check that we didnt truncate it which would cause the following connect() to fail. --- diff --git a/usr.sbin/smtpd/delivery_lmtp.c b/usr.sbin/smtpd/delivery_lmtp.c index b40dbc0e0d0..8fb47877474 100644 --- a/usr.sbin/smtpd/delivery_lmtp.c +++ b/usr.sbin/smtpd/delivery_lmtp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: delivery_lmtp.c,v 1.4 2013/12/26 17:25:32 eric Exp $ */ +/* $OpenBSD: delivery_lmtp.c,v 1.5 2014/04/19 11:29:06 gilles Exp $ */ /* * Copyright (c) 2013 Ashish SHUKLA @@ -116,7 +116,12 @@ unix_socket(char *path) { } addr.sun_family = AF_UNIX; - strlcpy(addr.sun_path, path, sizeof(addr.sun_path)); + if (strlcpy(addr.sun_path, path, sizeof(addr.sun_path)) + >= sizeof(addr.sun_path)) { + warnx("strlcpy: socket path too long"); + close(s); + return -1; + } if (connect(s, (struct sockaddr*) &addr, sizeof(addr)) == -1) { warn("connect");