From patchwork Wed Dec 19 11:19:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hauke Mehrtens X-Patchwork-Id: 1015999 X-Patchwork-Delegate: hauke@hauke-m.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=hauke-m.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="rW0gDexM"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43KXVX6XrMz9s6w for ; Wed, 19 Dec 2018 22:20:04 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=xMSTOD28swAospL+Km/tlCVrVc2TTSQgaOp7SmWmScU=; b=rW0gDexMOSY428 B6U4nOQ6g0P6fwf886S3OBHGo44KIAJtFVmxVwjawJMwHvne7xJEn28MX8DNAgxDhvRYKQdtZP3CM quSciDfMpGTWMPqYg0v9WEiT1VlgaUacxXqYZmyzznEkxepGdqLohGUvmSBColC1lk+jNLJdJvttD mwa5n9IMVcWOPCz58Ts6njj4lVOSGq8jaUa/AzSmI7dIdjGvACNLUhud4oXfEY/GlUuFDgyFl2/gX PcYaGUn8Ti8/Ncs6Fjt+j/LbbOhgvRWKrBYXhIEGvBQI35GXmScMbRmjuCQgvPovs+8NdnM5OY737 VB+lCEurDyO8knvsm8uw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gZZtE-0004Mo-Qd; Wed, 19 Dec 2018 11:19:48 +0000 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gZZtB-0004LU-I9 for openwrt-devel@lists.openwrt.org; Wed, 19 Dec 2018 11:19:47 +0000 Received: from smtp2.mailbox.org (unknown [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 8724E496CE; Wed, 19 Dec 2018 12:19:32 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id 2ZeqdEfAteox; Wed, 19 Dec 2018 12:19:31 +0100 (CET) From: Hauke Mehrtens To: openwrt-devel@lists.openwrt.org Date: Wed, 19 Dec 2018 12:19:01 +0100 Message-Id: <20181219111901.6730-1-hauke@hauke-m.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181219_031945_748231_26D3AA93 X-CRM114-Status: GOOD ( 11.98 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2001:67c:2050:104:0:1:25:1 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record Subject: [OpenWrt-Devel] [PATCH procd] hotplug.c: Make sure hotplug buffer is NULL terminated X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hauke Mehrtens Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Sets the final byte explicitly to NULL because we later do string operations on this buffer. Fixes Coverity issue 1430926 String not null terminated Signed-off-by: Hauke Mehrtens --- plug/hotplug.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plug/hotplug.c b/plug/hotplug.c index 80e6e4d..37b918e 100644 --- a/plug/hotplug.c +++ b/plug/hotplug.c @@ -545,10 +545,12 @@ static void hotplug_handler(struct uloop_fd *u, unsigned int ev) { int i = 0; static char buf[4096]; - int len = recv(u->fd, buf, sizeof(buf), MSG_DONTWAIT); + int len = recv(u->fd, buf, sizeof(buf) - 1, MSG_DONTWAIT); void *index; if (len < 1) return; + else + buf[len] = '\0'; blob_buf_init(&b, 0); index = blobmsg_open_table(&b, NULL);