From nobody Wed Oct 1 01:39:14 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548591574080549.5740003299958; Sun, 27 Jan 2019 04:19:34 -0800 (PST) Received: from localhost ([127.0.0.1]:44771 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gnjPP-0003lB-Ck for importer@patchew.org; Sun, 27 Jan 2019 07:19:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gnjCE-0001Pl-62 for qemu-devel@nongnu.org; Sun, 27 Jan 2019 07:05:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gnjCB-0007SN-RK for qemu-devel@nongnu.org; Sun, 27 Jan 2019 07:05:54 -0500 Received: from hera.aquilenet.fr ([2a0c:e300::1]:43410) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gnjCB-0007PL-FP for qemu-devel@nongnu.org; Sun, 27 Jan 2019 07:05:51 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 914E57CC7; Sun, 27 Jan 2019 13:05:39 +0100 (CET) Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YcoFuW9kWKct; Sun, 27 Jan 2019 13:05:38 +0100 (CET) Received: from function (lfbn-1-11161-124.w86-213.abo.wanadoo.fr [86.213.235.124]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 30DCC7CE3; Sun, 27 Jan 2019 13:05:29 +0100 (CET) Received: from samy by function with local (Exim 4.92-RC4) (envelope-from ) id 1gnjBn-00043A-EP; Sun, 27 Jan 2019 13:05:27 +0100 X-Virus-Scanned: Debian amavisd-new at aquilenet.fr From: Samuel Thibault To: qemu-devel@nongnu.org Date: Sun, 27 Jan 2019 13:05:13 +0100 Message-Id: <20190127120526.15457-19-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190127120526.15457-1-samuel.thibault@ens-lyon.org> References: <20190127120526.15457-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a0c:e300::1 Subject: [Qemu-devel] [PULL 18/31] slirp: add slirp own version of pstrcpy X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Samuel Thibault , stefanha@redhat.com, jan.kiszka@siemens.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau Remove a dependency on qemu util. Signed-off-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Samuel Thibault --- slirp/slirp.c | 4 ++-- slirp/tftp.c | 2 +- slirp/util.c | 17 +++++++++++++++++ slirp/util.h | 2 ++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/slirp/slirp.c b/slirp/slirp.c index 9ec1e4c62f..b5c4788489 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -320,8 +320,8 @@ Slirp *slirp_init(int restricted, bool in_enabled, stru= ct in_addr vnetwork, slirp->vprefix_len =3D vprefix_len; slirp->vhost_addr6 =3D vhost6; if (vhostname) { - pstrcpy(slirp->client_hostname, sizeof(slirp->client_hostname), - vhostname); + slirp_pstrcpy(slirp->client_hostname, sizeof(slirp->client_hostnam= e), + vhostname); } slirp->tftp_prefix =3D g_strdup(tftp_path); slirp->bootp_filename =3D g_strdup(bootfile); diff --git a/slirp/tftp.c b/slirp/tftp.c index 6fb381ef33..f0bcc72c92 100644 --- a/slirp/tftp.c +++ b/slirp/tftp.c @@ -216,7 +216,7 @@ static void tftp_send_error(struct tftp_session *spt, =20 tp->tp_op =3D htons(TFTP_ERROR); tp->x.tp_error.tp_error_code =3D htons(errorcode); - pstrcpy((char *)tp->x.tp_error.tp_msg, sizeof(tp->x.tp_error.tp_msg), ms= g); + slirp_pstrcpy((char *)tp->x.tp_error.tp_msg, sizeof(tp->x.tp_error.tp_ms= g), msg); =20 m->m_len =3D sizeof(struct tftp_t) - (TFTP_BLOCKSIZE_MAX + 2) + 3 + strl= en(msg) - sizeof(struct udphdr); diff --git a/slirp/util.c b/slirp/util.c index 59f6713c8b..84f5afdbc3 100644 --- a/slirp/util.c +++ b/slirp/util.c @@ -188,3 +188,20 @@ int slirp_closesocket(int fd) return ret; } #endif /* WIN32 */ + +void slirp_pstrcpy(char *buf, int buf_size, const char *str) +{ + int c; + char *q =3D buf; + + if (buf_size <=3D 0) + return; + + for(;;) { + c =3D *str++; + if (c =3D=3D 0 || q >=3D buf + buf_size - 1) + break; + *q++ =3D c; + } + *q =3D '\0'; +} diff --git a/slirp/util.h b/slirp/util.h index 4f6e80c3ed..586517bb30 100644 --- a/slirp/util.h +++ b/slirp/util.h @@ -91,4 +91,6 @@ static inline int slirp_socket_set_fast_reuse(int fd) #endif } =20 +void slirp_pstrcpy(char *buf, int buf_size, const char *str); + #endif --=20 2.20.1