From nobody Sun Feb 8 22:08:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576070604; cv=none; d=zohomail.com; s=zohoarc; b=GRT+8GOSi6UDDqXmU6B/tAY8FuTHV+74UvFCE++C/RTfZyhmnfEQxK9iDz4wbA87jGJP0ia6udAGLDC0Ajt96KT6rgxgrydiAAG5FRsR/ynXkYxddvcEABZ8tEB4qAHoKx8ASVMTdOA9QNqmZgS5aCvdxwa/QIQ7Q34UHylvnlU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576070604; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ropkeQiqxkSEacUb28fHpJDd1Il6T3xVUsdaZCHiSFI=; b=N/lk4rnH02/WV4Ztp2fuALXP/wNhozSKEvqEC6MsxU2eiCOj7ZG30tp1zifmxcHHVLNge6VwBBUi7xPBDtPqpCX8LNeSBZW6wEBnoD0b4HDGv4YpNmd9yRdXacjlg3UbVLd/l351Pm79oSneyaet6Gjh4PsTZoH0/AxlTCtgg80= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1576070604413154.95435048929915; Wed, 11 Dec 2019 05:23:24 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-64-c2aIoQDgOJWc6jRa4dM5Eg-1; Wed, 11 Dec 2019 08:23:20 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 31235DB20; Wed, 11 Dec 2019 13:23:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 08E601001938; Wed, 11 Dec 2019 13:23:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B3CE683714; Wed, 11 Dec 2019 13:23:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBBDMXPX019795 for ; Wed, 11 Dec 2019 08:22:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 414B963BC6; Wed, 11 Dec 2019 13:22:33 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.43.2.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE6E963BBA for ; Wed, 11 Dec 2019 13:22:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576070603; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ropkeQiqxkSEacUb28fHpJDd1Il6T3xVUsdaZCHiSFI=; b=S5hjNf3s728qNy6vwHzQ/C/R7vhacSfJ5PmvZcbJGuus28vyIXdEcVq3zseA5J0QGT+ocG bQRFFmKIjUUFJMk5qGNto/t0uA82Q0E4Cwu+ms/ImUPtzFqdKQWLmRjOfEe4l2v31dvrx1 H4PJQfeXN/1BHSCMm47kBRcOcbsSQb8= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 11 Dec 2019 14:23:19 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2 3/8] Remove VIR_STRNDUP usage with checked pointers X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: c2aIoQDgOJWc6jRa4dM5Eg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Remove the usage where sanity of the length argument is verified by other conditions not matching the previous patches. Signed-off-by: J=C3=A1n Tomko --- src/libxl/xen_common.c | 18 ++++++++---------- tools/vsh.c | 5 ++--- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 8c07df80b6..912dd8834a 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -815,9 +815,8 @@ xenParseSxprChar(const char *value, goto error; } =20 - if (offset !=3D value && - VIR_STRNDUP(def->source->data.tcp.host, value, offset - value)= < 0) - goto error; + if (offset !=3D value) + def->source->data.tcp.host =3D g_strndup(value, offset - value= ); =20 offset2 =3D strchr(offset, ','); offset++; @@ -843,9 +842,9 @@ xenParseSxprChar(const char *value, goto error; } =20 - if (offset !=3D value && - VIR_STRNDUP(def->source->data.udp.connectHost, value, offset -= value) < 0) - goto error; + if (offset !=3D value) + def->source->data.udp.connectHost =3D g_strndup(value, + offset - value); =20 offset2 =3D strchr(offset, '@'); if (offset2 !=3D NULL) { @@ -860,10 +859,9 @@ xenParseSxprChar(const char *value, goto error; } =20 - if (offset3 > (offset2 + 1) && - VIR_STRNDUP(def->source->data.udp.bindHost, - offset2 + 1, offset3 - offset2 - 1) < 0) - goto error; + if (offset3 > (offset2 + 1)) + def->source->data.udp.bindHost =3D g_strndup(offset2 + 1, + offset3 - offse= t2 - 1); =20 def->source->data.udp.bindService =3D g_strdup(offset3 + 1); } else { diff --git a/tools/vsh.c b/tools/vsh.c index dd2c039b47..5ccda5ab44 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -348,9 +348,8 @@ vshCmddefCheckInternals(vshControl *ctl, cmd->name); return -1; /* alias options are tracked by the original na= me */ } - if ((p =3D strchr(name, '=3D')) && - VIR_STRNDUP(name, name, p - name) < 0) - return -1; + if ((p =3D strchr(name, '=3D'))) + name =3D g_strndup(name, p - name); for (j =3D i + 1; cmd->opts[j].name; j++) { if (STREQ(name, cmd->opts[j].name) && cmd->opts[j].type !=3D VSH_OT_ALIAS) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list