From patchwork Mon May 27 10:18:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1939834 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=Nvp49qA4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::438; helo=mail-wr1-x438.google.com; envelope-from=swupdate+bncbd2zdgn6sekrbb542gzamgqelarxlzi@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-wr1-x438.google.com (mail-wr1-x438.google.com [IPv6:2a00:1450:4864:20::438]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Vns7R2gwnz20f2 for ; Mon, 27 May 2024 20:18:58 +1000 (AEST) Received: by mail-wr1-x438.google.com with SMTP id ffacd0b85a97d-35507e4c41dsf1180491f8f.1 for ; Mon, 27 May 2024 03:18:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716805129; cv=pass; d=google.com; s=arc-20160816; b=A901eaSCvooZq1mRkGGktncBlUrn7ntCpm1egGTsjx+6zU5Et64bUiWnc49a1bYY8u 8Zg2cQafxIW3RCCanyq4o+XF3n/EzhOlYlg6ibIPLgkKXbolka9yxtnBCoaLA7MMSMG5 AxXm6cqrsKxszTeEUowCK5KAfO84mE5oScaPS+tiNgYGjDF2GHmSnS3WD5E5Z4LNOFRh 7m7VZuLYwHzEoEJkclPdDIJ/traH7z3TwlDXUrSqRV5aPoyb0wjri2YYYbHqE3xXweG0 eW+G0ceuG/dNaCuq6AEBvjTJDzROi//nRmJy64Y3L1Qt+MmoayfitRVE7mro7E0rW1nz pOFQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=9oVVOsOwu4BdAUU4WbU281H3SVDqqQbNKdxbif6TtxI=; fh=EtvaiTo9GiDavZN76w9P60vCXmGor2Pp7yLxwCD53ZY=; b=css3LkJFFbcuxfiI4xPgGXuMc/Ctyj4t1zxl8DmZ4pQqAK2q9MBM6rlC7sBHeKvB/X ezCa6Vc1E4h8K7ZkhGlaFynr/Z7ZMhfp4v3x7r9writPTtoPZ3jzm1VKNSeVqa/VFBvX Yg7/koWYwlf2pNPX/ItAL9yRLLAsJQOPwqWOa8suSDh6NVbshlRddA1WAwxC6kf/67O8 sGz6vy7BeKUulvfj/VErVApAOm/0V3ihVnhVJ20dAQhmcRPT08zvhxxCaI1pm4WFNrhM zuipxgx7XCt3Gv/wtpb3ESWsGbue0tHaU6X1V+Q0NtMGYKVOC/wT3M8QXzQvO3Rrum9h ILBA==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=RELrv2BX; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.135 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1716805129; x=1717409929; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=9oVVOsOwu4BdAUU4WbU281H3SVDqqQbNKdxbif6TtxI=; b=Nvp49qA4wreLZbdoDL+uxzKIH6djo+iNdJBbLgiRiEhDNeXpWJ8TwvJKZKJl/LvVym LGaxIdHpzuMHJyPWSlpm6JfjNM8EXECnLLAYT3dzMEHtfVu3ehQa0hDoVyGrkxEkhK8K Gu/j+5m6alNpAUDQMFQPGjnoNt2d0ZFTPvTnB8DPXuPjjmsaAN9u4096Na76AumIuTEP AKsxGh0XBi6kSN6cjRBMRx+eXEOk8/1qlN6Y4dOHFA/GVb01iA4/HGYtl7ysNDmE/3tV 7VNN6XpAdolV1s0WGOzxWw6/2U3NZRBfKpEzNtj5wLrKZYNtQopXkXLUSIF7l3n8wzTZ 7qxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716805129; x=1717409929; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=9oVVOsOwu4BdAUU4WbU281H3SVDqqQbNKdxbif6TtxI=; b=VjEIoHTKeyPsf8hF8VlfQHvhnMg53t4SMtxGLT3b/HiPhVwmQfveeSfvUAyw3Lob59 mablV0Q17r9xGCd2iQVyeTc9P8oaN2vyS8nR8sFEZENL20PLk1QsMvDQT2RNwYi+8P6+ 6PbVKOxQ7GJjEs7X/pG6y0de7NXE30umYePA4mCwgb3fEJ9KIe37tNVEaYEXu1/uQmgT 7CTkhYZjqnErIZ/NcMCZYsUmDbOtbqvFeeNjqtSPh4j6XiTzTZ0Lt4Fh4hcwOUtyUF+S IEb9AdMrmBjcA4yWm710fybKK2zfO5nqa77MAykte3Acp74hRjc0ONO+8BZv/usVGSZn 2nMA== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCWZxQjRaTUH5d2FtxezqJSb7MF81UQl5JulX+0sPWl+xG+VhCZFhGaZ7ccByGobiKBlzVhjbe66oWJ+SpjBZjeRKPRpc5Fy4mf6Nx2qQg== X-Gm-Message-State: AOJu0YxCmEsvD/GZLnsgdkkoHgGk1vtXVdwFmIXzoS4VBJAq9scjpZ8K oecQ2LajeZxL5KZN2xBgmuzOXY+6VCWu2bqpDVawEfoblqAPCPue X-Google-Smtp-Source: AGHT+IHuZtAEFpHgBqa33VzD+q6EXA09FP9RcZWL0dBhgmOdW1oc8sVs+vNWKAdBlN1aa/ogRzmfRA== X-Received: by 2002:adf:fa02:0:b0:354:c330:5d2a with SMTP id ffacd0b85a97d-35506e04debmr6313322f8f.35.1716805128665; Mon, 27 May 2024 03:18:48 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6000:1867:b0:354:de3c:6ee3 with SMTP id ffacd0b85a97d-35504ccc375ls1177477f8f.0.-pod-prod-00-eu; Mon, 27 May 2024 03:18:46 -0700 (PDT) X-Received: by 2002:a5d:664f:0:b0:357:65c9:84d0 with SMTP id ffacd0b85a97d-35765c9869cmr3501495f8f.22.1716805125867; Mon, 27 May 2024 03:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716805125; cv=none; d=google.com; s=arc-20160816; b=V2GM8PbG86ALVP8ua3UaEdd65myZX75UHH8jMxQGlTP4QcoqrKp+9F9MmD2DIYmAf1 z2BLIMh0D6eFpt4xfe4hHPLwK1XImuAhWNE6RlDue8lwgGMXjtMr0r01zKzNSal6Ridi 7K0W7ErnVQqfPRiupHFcA+AwW7XTQYim3uk+sP8xk5jKCQwDIrqjY6PrUTIR0jYrBnVh iFtj6uC589+fCbWT6VLQoQ2gUwkFrLECPPk4vRujGePPaFqydTGn4yZy6a8KBug1A/qg 7Gm3Q4LY3CJHm4MYx/hALZcj5XMTx7GGTRhAtcFlITFGTOg+6QX9bIp1WO12riffivmz iHUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=hPMeSRFOEWZzYiSP6XC7+krP3vl3FE4UT6f4RtW2T0c=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=QNAaI6CAMvUdGBPvEgD0D7FtVUAp9UCeepoe8Unm4Yii53XD3PjQAzFrMKbtgV9LZY 8QQKzan+zUiIc6CDQXoZMONcqZnDprDg+ZQOow5Z1ylDGGxuXvA8YNBTU37+xT/w+rxf rylKo3pZh1R9hyyI6KmAHbc9QmjYdmbE1pObsm9ABZsg7ufuav/LC06Uk++eSuM1Evl8 /RjFWzExNhbqaIrNz0Olqg1Gl8UTevhXidZjruv/495P97ZkW9ozkWyjQ4zguQm0vSmk 768iq3G2iqzxFjLb7Q3kDWqsLSw7zsn0Fdcdcy2IhWXDdYTw+6lxDuPKJmwFs1CUppYv NMBg==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=RELrv2BX; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.135 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.135]) by gmr-mx.google.com with ESMTPS id ffacd0b85a97d-355731b6bccsi154373f8f.7.2024.05.27.03.18.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 03:18:45 -0700 (PDT) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.135 as permitted sender) client-ip=212.227.126.135; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue009 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MOiLv-1rrMhG1v6F-00IX0l; Mon, 27 May 2024 12:18:45 +0200 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [libubootenv][ 2/3] Remove warnings Date: Mon, 27 May 2024 12:18:42 +0200 Message-Id: <20240527101843.380555-2-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240527101843.380555-1-stefano.babic@swupdate.org> References: <20240527101843.380555-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:uv58PczHHZrTgGeotjLmPcQjpRp0ktJ9iRu2G6RGoB0N7OqkRH2 KFVxkshbMqBns2RgbzLqmuzfk+duUrCTdraD/0LLHOjRvhs9yqo+YrisgY1obhKfDp43jdj m/zSvs6ZWlnF+baQSbEJ7oHAtRDQDxpE5BlOOMHNC7kYfq0QfXjkF/5QwwU562NEy7HBtuA CH6MHPtBY9M6jsrWWWNzw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:j1xuJ8ctHYE=;oQ7mhJFq6dLn3iQNjUBaXq3u1bG fRFULGH0at/hZj+R79N7E37LYW05Xx+1ns9jrsXEAD/OQBUZZGn7IXiXhxHqrC11/p4fuuue4 0P8ZWFxUvQcYHhwFeI7NDRXwzJyXAhpO8bTcA4BRWs2d13URmEiMzDidUnnovl5lVptL7M8rH Pp9xz/j22bZvt8TrB79wizQT1MN/xO9WdXLMXpJ6tKCLFML9CdBLCdqRX4gN/i3rwGyhT8qmb sxh7nTUL+WOMvPAEVMPLCeZ0Dmb42hJK1CHp8EuK5+zTjuRZ3JpRNChFaYWRa+qQoZH6A7lV9 837LsoQc2ZjabAZ0IJlgg1HaQN0NJbrnbZRlWuLnMiE5tEOnWBS7oEX32q2tSgK2EYBtk5CK4 QDrtmo00PBHJ8iRHPL57ilck4n3edF6ai2EFPQ74FJKntLvcdyGHSs/lW8xmpQFUJX3p/71fm CH/whk/db2TbbqXQ5HUoHP6HO65+TU7UWtSeQoNz657jbczJTUBKrWtfTc2Io2JVFolnUfTB9 zCcsveMoCS8E3pBkDlPlvvNe4ajP/JiyAXIh1xK2a/WjaYBuV26ggtHafgUlzXDgtump3vgJI BgpzlzwWyITrzvmpGPHEfyfd7N8+5zqTs1bB+iPYwhPSSWElGM8ckz/dbiKDzGA5yDDYchbtR gRirViuzhP+3ENfzAHVp8epm14z+sBzskidKz3GqFy8IAOVUjW8pPK10RW3ejWXC4KBs/upJN N67plf6tZRCoToR4MRbYqAEi/n++5B3DZqXMotxuK1LbnSO4sqNzFs= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=RELrv2BX; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.135 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Signed-off-by: Stefano Babic --- src/uboot_mtd.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) -- 2.34.1 diff --git a/src/uboot_mtd.c b/src/uboot_mtd.c index e5a9ce1..3d8c553 100644 --- a/src/uboot_mtd.c +++ b/src/uboot_mtd.c @@ -218,8 +218,9 @@ out: int libubootenv_ubi_update_name(struct uboot_flash_env *dev) { + const size_t VOLNAME_MAX_LENGTH = DEVNAME_MAX_LENGTH - 20; char device[DEVNAME_MAX_LENGTH]; - char volume[DEVNAME_MAX_LENGTH]; + char volume[VOLNAME_MAX_LENGTH]; int dev_id, vol_id, fd, ret = -EBADF; struct stat st; char *sep; @@ -232,7 +233,7 @@ int libubootenv_ubi_update_name(struct uboot_flash_env *dev) memset(device, 0, DEVNAME_MAX_LENGTH); memcpy(device, dev->devname, sep - dev->devname); - memset(volume, 0, DEVNAME_MAX_LENGTH); + memset(volume, 0, VOLNAME_MAX_LENGTH); sscanf(sep + 1, "%s", &volume[0]); ret = ubi_get_dev_id_from_mtd(device); @@ -263,9 +264,9 @@ int libubootenv_ubi_update_name(struct uboot_flash_env *dev) } } - sprintf(dev->devname, DEVICE_UBI_NAME"%d:%s", req.ubi_num, volume); + snprintf(dev->devname, sizeof(dev->devname) - 1, DEVICE_UBI_NAME"%d:%s", req.ubi_num, volume); } else { - sprintf(dev->devname, DEVICE_UBI_NAME"%d:%s", ret, volume); + snprintf(dev->devname, sizeof(dev->devname) - 1, DEVICE_UBI_NAME"%d:%s", ret, volume); } } else { return -EBADF; @@ -273,6 +274,7 @@ int libubootenv_ubi_update_name(struct uboot_flash_env *dev) } sep = strchr(dev->devname, DEVNAME_SEPARATOR); + ret = 0; if (sep) { memset(device, 0, DEVNAME_MAX_LENGTH); @@ -289,10 +291,10 @@ int libubootenv_ubi_update_name(struct uboot_flash_env *dev) if (vol_id < 0) goto out; - sprintf(dev->devname, "%s_%d", device, vol_id); + if (snprintf(dev->devname, sizeof(dev->devname) - 1, "%s_%d", device, vol_id) < 0) + ret = -EBADF; } - ret = 0; out: return ret;