From patchwork Sun Jul 19 13:36:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin 'ldir' Darbyshire-Bryant X-Patchwork-Id: 1331806 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=darbyshire-bryant.me.uk Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=Ra/wBod/; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=darbyshire-bryant.me.uk header.i=@darbyshire-bryant.me.uk header.a=rsa-sha256 header.s=google header.b=gUp84Zzd; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B8mDs1gCrz9sR4 for ; Sun, 19 Jul 2020 23:39:39 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject: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=NFckQ8GRxcszist+jBDw+/xkPeR9BHAwKLPzD72Fj5E=; b=Ra/wBod/UALFLlTAOkDZaf62aX z6s9O3UT6U48Noq098rnbuo16sOM8fsWQE5yFGGTvwFus6pqlcq7IGK6apHz+BqyFCzimyUMJ/ivS qeB556VQeI+c3YtHMb2B45ie7sDIHbeFrY3fsyFCsXtc1Jswv+AjwKKBD1cWT0OWhgPBef+yFQvU/ Ee++nbP6wzG0JlwkSJKwU1PnVPaBGiBBcbpeS+vczyARSqepNMdkpuoHFrc89yXcixaqaJBObd/w9 mQH2ozWiQGabqQjAxsNB2C9a1PkrkUYQg6ZLhCRj0Xh9kcZmEI6dDAmUn6wquXds2peJ3YnWri//J kQSVxnMA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jx9V1-00006u-86; Sun, 19 Jul 2020 13:37:03 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jx9Ux-00005z-0j for openwrt-devel@lists.openwrt.org; Sun, 19 Jul 2020 13:37:00 +0000 Received: by mail-wr1-x442.google.com with SMTP id q5so15334387wru.6 for ; Sun, 19 Jul 2020 06:36:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=darbyshire-bryant.me.uk; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EDKvhdgSkGGh9JMKn5SZnX7tJl7qFvaQpYVNdCPkRMU=; b=gUp84Zzd5hFY9S04XWaY3J3m/ESFgI1HqYgsslkhZD4qocta/cmxxbN3xj+LGIrWjo YsRYDCCyWFkUH5+rcUinZW6S5B4EfDR9k+AduPcfx3gchlSkJcVxRbjQxQ5Ixbce+59C Np0Mq4LEj1Z2p1Mwn0OQmWHEi4wo/u1+X/L9k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EDKvhdgSkGGh9JMKn5SZnX7tJl7qFvaQpYVNdCPkRMU=; b=mHy37M1MxJBfjm1821ty/p9zDHALVFxWD+s/bZh/f/0yTk8V/9vz8+SL35LnoWINNL rKVSb1slP1ORGohyt+CrMNYFEnqGPc4eatVXQ50L/AgpcsUvBy4uiA9+yiEGpzRMmAuC x6SSbtog90EvAXUsS2DxlNvgRC9903hXtfj1T8c2q/p4sNxj2c3496HiDNq5t0V4r+oh K2CEK0Vsd+BjTIcfKD8C0xxFE000BfkO2+qqPUQcLn1t8/EVlc5CZD2atNsycUE/Q5nY JAAQnv4YBBfsBMsB9Zpli8/D9SPswGHFSL/ZoC+OJCt6HI4l+oCHsd6mjq8TYqoqsy6k wM7Q== X-Gm-Message-State: AOAM533/4khkUkeVDh9QkO8uxHu2awnSEdJN1zs1dmhoHDDhIcStnLAj /on71OHRyaZkA6hiBKUHtLd6pOy96e0= X-Google-Smtp-Source: ABdhPJxT9nWcSM/Jwz3l362cKTqmEdnBpGftwOvm1ghE1oYINEDrLBO8/K+uHapi+qb8l6Yp5qdUqQ== X-Received: by 2002:a5d:690a:: with SMTP id t10mr5706950wru.374.1595165813918; Sun, 19 Jul 2020 06:36:53 -0700 (PDT) Received: from Kevins-MBP.lan.darbyshire-bryant.me.uk ([2a02:c7f:1227:c00::dc83]) by smtp.gmail.com with ESMTPSA id x5sm26670583wmg.2.2020.07.19.06.36.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Jul 2020 06:36:53 -0700 (PDT) From: Kevin Darbyshire-Bryant To: openwrt-devel@lists.openwrt.org Subject: [PATCH umdns] service.c: fix build on gcc 10 Date: Sun, 19 Jul 2020 14:36:50 +0100 Message-Id: <20200719133650.27522-1-ldir@darbyshire-bryant.me.uk> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200719_093659_174693_DCD8890A X-CRM114-Status: GOOD ( 10.60 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:442 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Darbyshire-Bryant Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Resolve error: /Users/kevin/wrt/build_dir/target-x86_64_musl/umdns-2020-06-08-d13290b4/service.c: In function 'service_load_blob': /Users/kevin/wrt/build_dir/target-x86_64_musl/umdns-2020-06-08-d13290b4/service.c:240:10: error: 'strcpy' offset 6 from the object at 'b' is out of the bounds of referenced subobject 'name' with type 'uint8_t[]' {aka 'unsigned char[]'} at offset 6 [-Werror=array-bounds] 240 | s->id = strcpy(d_id, blobmsg_name(b)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /Users/kevin/wrt/staging_dir/target-x86_64_musl/usr/include/libubus.h:23, from /Users/kevin/wrt/build_dir/target-x86_64_musl/umdns-2020-06-08-d13290b4/service.c:23: /Users/kevin/wrt/staging_dir/target-x86_64_musl/usr/include/libubox/blobmsg.h:42:10: note: subobject 'name' declared here 42 | uint8_t name[]; | ^~~~ cc1: all warnings being treated as errors make[5]: *** [CMakeFiles/umdns.dir/build.make:132: CMakeFiles/umdns.dir/service.c.o] Error 1 Signed-off-by: Kevin Darbyshire-Bryant Acked-by: Jo-Philipp Wich --- service.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/service.c b/service.c index 97b6f91..af3083e 100644 --- a/service.c +++ b/service.c @@ -218,6 +218,7 @@ service_load_blob(struct blob_attr *b) uint8_t *d_txt; int rem2; int txt_len = 0; + unsigned int n; blobmsg_parse(service_policy, ARRAY_SIZE(service_policy), _tb, blobmsg_data(b), blobmsg_data_len(b)); @@ -228,8 +229,9 @@ service_load_blob(struct blob_attr *b) blobmsg_for_each_attr(txt, _tb[SERVICE_TXT], rem2) txt_len += 1 + strlen(blobmsg_get_string(txt)); + n = strlen(blobmsg_name(b)) + 1; s = calloc_a(sizeof(*s), - &d_id, strlen(blobmsg_name(b)) + 1, + &d_id, n, &d_instance, _tb[SERVICE_INSTANCE] ? strlen(blobmsg_get_string(_tb[SERVICE_INSTANCE])) + 1 : 0, &d_service, strlen(blobmsg_get_string(_tb[SERVICE_SERVICE])) + 1, &d_txt, txt_len); @@ -237,7 +239,7 @@ service_load_blob(struct blob_attr *b) return; s->port = blobmsg_get_u32(_tb[SERVICE_PORT]); - s->id = strcpy(d_id, blobmsg_name(b)); + s->id = strncpy(d_id, blobmsg_name(b), n); if (_tb[SERVICE_INSTANCE]) s->instance = strcpy(d_instance, blobmsg_get_string(_tb[SERVICE_INSTANCE])); else