From patchwork Thu Dec 31 10:29:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1421528 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=googlegroups.com (client-ip=2a00:1450:4864:20::43d; helo=mail-wr1-x43d.google.com; envelope-from=swupdate+bncbcxploxj6ikrbggqw37qkgqetr5rg5i@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=VBcLm5Sv; dkim-atps=neutral Received: from mail-wr1-x43d.google.com (mail-wr1-x43d.google.com [IPv6:2a00:1450:4864:20::43d]) (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 4D64Cc59VQz9sRf for ; Thu, 31 Dec 2020 21:29:48 +1100 (AEDT) Received: by mail-wr1-x43d.google.com with SMTP id o12sf9726883wrq.13 for ; Thu, 31 Dec 2020 02:29:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1609410585; cv=pass; d=google.com; s=arc-20160816; b=SKuh7IkIKw5fyUwlTG6thLTW9IdMCqOAmQMatPmqSfqTGXs0A2e+Bj4S/wu3Lq5tAM UhtuAVoVGcvllEYPhgC1YHp2y6Zlg2iyzes+FZlms2xpY1eBxFdpfxMMMRUeH4f9VnLh n8OzBRQOviycPnzBYiDQr2C+d3k3D8PTskUIYkcyaDiw79xcy+O5gDUvaKCQbUXVPMzF CSLvi2WmPEzigEmpYRabmdWKmphVcspQOBVpg/sMdyBgJFFeOsLEe+iJyDxfNZriVrmp 0epHRkm26s7cEJBjj8FzWVplQVXkby5LsbFSCrZPRVQTMBukuWdksxmgLAg1FQnp44oq 1EsQ== 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:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=UXsK1n9b1aGURsnB6zO7WVzfphAbJTUE1+AXaw5wzMQ=; b=KZNSn9r5wMVuDIzKBYRf9rUu5KdGpXe/2kprzYsiksaKPOT2lcPyF94wQ3gZa1G851 rE119cd/KSS6Jn15rAYXZ0Txjqtz20zKLB2pF5bKcADWCJx8eXeSCEyLjH0w70LDnZf7 ZzAtMDrk1AOwXE4sEAA+6JOmquggp/MLh0fwlXw4Ie7C59iSmFkL2COjYvG2lQ1rN784 7Qy+pwryJMfFT7O1i0eX/A0x8D1OwJSZ75MxX4W3Cel8RGO6u0TMTqvd+NTISFBq8Nzv vhZCW32uJjw+HQy8tlqU0x5uA1wHNPnHGYTBWE2s9fid5G4Z8d9fo8VxjdG/ATqwAPgg W8zw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=UXsK1n9b1aGURsnB6zO7WVzfphAbJTUE1+AXaw5wzMQ=; b=VBcLm5SvASvg3pynZaUwjVB8aohllPz8jE9y78vjPt5yBnQEM4wbaPVK5ZiVvUdBic d2hLp6fxUTc/MKqcUTXiHEIqBOtB/+ufkji9N69uru65qcJq6ng6W9/ujFaLbAG80fTj ZsHgvPLxjRwrtuVbe3S4ga6eZjCa2m/rtgBAcbSK9qaJWCfcwlAAF18p9UW04kjL4wni PNNMcjrE/7Aqx2A4fvGDpSIwCg69yoEbGogo1pygI6YUvdhhs6+nEtIuxu9fnYdLXD6Y zHcGJpo9sD84BXV78gbHtZw1t85B21LZ1kyoF9dIlUeOBwj81fkq8qkpacb9QBg0VRR4 5E0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=UXsK1n9b1aGURsnB6zO7WVzfphAbJTUE1+AXaw5wzMQ=; b=RBYjNYoxMib9o01IXiG0W2WT4bP9XNF6AWB9spxBXpj2hfP1TQZ7NxHOSCdhvqwJN9 U+HQvgoA9xah58ovw+MGQdW8UXT3eZUjmjhJT93jolAd6Pri6CRpWznABssMv54Ow4Zn wNhKU5Y0NBkfe9MsO+zkkpPV/gKpznZdIOxlC61TcNMwjUgGZsrjOxXaRAr6owUL0uUg 7DbSQn9r/FpspPLGudsLGFBs2Tf1K8r/spc4IO5JoezmIjY7HwBj27LoohplG6t8+JQO /t1xzzJyplOiiCeaH+t6qFwSlRtKzZ/5NNC8Jo5e5tH1JcxBDRNk43Klv15Xcg1f5APF Lr3Q== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530UJE8QktPIg+Xgv4XIEy6xhizG+4Cm3Td+OmZmNWELc4JjSJt7 m8f9XevEG7URt6kpfGUFfjc= X-Google-Smtp-Source: ABdhPJzQLLato7l7+KfUOL7UjPh+4xBwZI7NYhXxyfaQSWd2TLG2jgOonWkRpmAZxMaFN7k620xhYg== X-Received: by 2002:adf:ed49:: with SMTP id u9mr65169924wro.292.1609410585183; Thu, 31 Dec 2020 02:29:45 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a7b:cbd5:: with SMTP id n21ls3780454wmi.3.gmail; Thu, 31 Dec 2020 02:29:44 -0800 (PST) X-Received: by 2002:a1c:9d16:: with SMTP id g22mr11138250wme.140.1609410584252; Thu, 31 Dec 2020 02:29:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609410584; cv=none; d=google.com; s=arc-20160816; b=atKhybER0xkoqbg56HhrnC7xYFWC0xCXuyD47lo4/QZSbX7aimBET9jkNnwteY0OfK r/ezUp1MvuPCkXrQLn/YrVXxQIa93PLkDayJJQtclYVQXth7N/W4mpVB/3hWlij/RFA4 24E6/P3vovWJlnqhuhdVzb7dEE9Mqa1QMtnCY6pMZ2RcNZAg/BAIay9WJs1cldPwIwSE UVSIY7/vDnjvma4Yfw0NKWzV3yuvrNafHhAEvrd6gyfj0XItTZHo2wklinEIMZMSfS76 vxRKc2CozT++dnjBj7KN3yJk6absQxKQSHSm9PIkQ9YTqh4zzm5IKIzp2VePoov+AZ3E sGqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=3aIbNuiwiBwOCY1Pn3e9huvZ+mSWYe5NhiT1gZAok6k=; b=kXOSjj9/12/WpCz3CfitG3XCH8W4xJrYbH/DTCO7lhbfqsl/75Ku3E1j4NgVEG601p 69NnM/MykaM6fzMNhJz/lq78iXltD3jw7PLvvCHMpNbTCQ6SK8ojBcEfDBH3uEGUIHGT RbWqixTO1o5IL7ChauUGZ/+3+KCJbLHF0YZjIILIAWBllAFknCFL76r3/s6kt3XtKJPN 73kU6Y7NvIwpARqfoPeo2caCXgV8Ei7s0/sLeLKR5ObAZR0EyIkgmO7vd/uR9YC+KAyr 3G8w9H5wr6uXTzK+NPCIGOZX+kIAe5pDSQ8LFq0mPQw/feFjTGI6FWa6NCTBObcD32S7 js7g== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id o135si266295wme.3.2020.12.31.02.29.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Dec 2020 02:29:44 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4D64CX0XjNz1qs3x; Thu, 31 Dec 2020 11:29:44 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4D64CX0Dm6z1tYWb; Thu, 31 Dec 2020 11:29:44 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id m-57rhWELzjg; Thu, 31 Dec 2020 11:29:43 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Thu, 31 Dec 2020 11:29:43 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id DAA104540062; Thu, 31 Dec 2020 11:29:42 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id e-RUsHTJ-prE; Thu, 31 Dec 2020 11:29:40 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id 093C84540BCB; Thu, 31 Dec 2020 11:29:38 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic , Bastian Germann Subject: [swupdate] [PATCH V2 2/2] Added missing copyright for strlcpy function Date: Thu, 31 Dec 2020 11:29:35 +0100 Message-Id: <20201231102935.85706-3-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201231102935.85706-1-sbabic@denx.de> References: <20201231102935.85706-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de 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: , strlcpy() does not exist in Linux and the function in SWUpdate was taken from FreeBSD code. Add the missing Copyright of the author. Signed-off-by: Stefano Babic Reported-by: Bastian Germann --- core/Makefile | 3 ++- core/strlcpy.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ core/util.c | 33 --------------------------------- 3 files changed, 47 insertions(+), 34 deletions(-) create mode 100644 core/strlcpy.c diff --git a/core/Makefile b/core/Makefile index 11bc183..0ad6f22 100644 --- a/core/Makefile +++ b/core/Makefile @@ -25,4 +25,5 @@ obj-y += swupdate.o \ parsing_library.o \ artifacts_versions.o \ swupdate_dict.o \ - semver.o + semver.o \ + strlcpy.o diff --git a/core/strlcpy.c b/core/strlcpy.c new file mode 100644 index 0000000..3c8dca4 --- /dev/null +++ b/core/strlcpy.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 1998, 2015 Todd C. Miller + * + * SPDX-License-Identifier: ISC + */ + +#include +#include "util.h" +#if defined(__linux__) + +/* + * strlcpy() does not exist in Linux, and this function is copied from freebsd + * + */ + +/* + * Copy string src to buffer dst of size dsize. At most dsize-1 + * chars will be copied. Always NUL terminates (unless dsize == 0). + * Returns strlen(src); if retval >= dsize, truncation occurred. + */ +size_t +strlcpy(char * __restrict dst, const char * __restrict src, size_t dsize) +{ + const char *osrc = src; + size_t nleft = dsize; + + /* Copy as many bytes as will fit. */ + if (nleft != 0) { + while (--nleft != 0) { + if ((*dst++ = *src++) == '\0') + break; + } + } + + /* Not enough room in dst, add NUL and traverse rest of src. */ + if (nleft == 0) { + if (dsize != 0) + *dst = '\0'; /* NUL-terminate dst */ + while (*src++) + ; + } + + return(src - osrc - 1); /* count does not include NUL */ +} +#endif diff --git a/core/util.c b/core/util.c index 69d02c5..2025276 100644 --- a/core/util.c +++ b/core/util.c @@ -223,39 +223,6 @@ char *substring(const char *src, int first, int len) { return s; } -#if defined(__linux__) - -/* - * Copy string src to buffer dst of size dsize. At most dsize-1 - * chars will be copied. Always NUL terminates (unless dsize == 0). - * Returns strlen(src); if retval >= dsize, truncation occurred. - */ -size_t -strlcpy(char * __restrict dst, const char * __restrict src, size_t dsize) -{ - const char *osrc = src; - size_t nleft = dsize; - - /* Copy as many bytes as will fit. */ - if (nleft != 0) { - while (--nleft != 0) { - if ((*dst++ = *src++) == '\0') - break; - } - } - - /* Not enough room in dst, add NUL and traverse rest of src. */ - if (nleft == 0) { - if (dsize != 0) - *dst = '\0'; /* NUL-terminate dst */ - while (*src++) - ; - } - - return(src - osrc - 1); /* count does not include NUL */ -} -#endif - int openfileoutput(const char *filename) { int fdout;