From nobody Fri Mar 29 02:20:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1596185786; cv=none; d=zohomail.com; s=zohoarc; b=kyyUpVs6VAkfathDm1PwxEThCC0xGzBGRqvQWTZb/MaUefdK3z1yg8IAALednBp9H9gBbgXU+KrKcvUg1yUNVtFX+unkm6o7l+YNf2O5cWxL0M4SP+jcHtX6HfoYoNaC5uNhlI36Nil06jnw0PVJzmarpYO6XZdvtG2Dw5svfgk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596185786; h=Content-Type:Content-Transfer-Encoding:Cc: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=wu8Rc6eY4ey6WmkOwRjSnVil7pcllEVWfjJR7NyKsoM=; b=lKZBANpC94qcHNpPjmIunX0eE/cqnhcyud6ZD+MqT0WLe9msaufH6WkHWEZ3Ptilh/bMmk/6eki8lkhUveuCr8aRRrFkWApLC07SBXmNg7XF6XckP3utfl6dhGQTCtM3KcpgJZeUO6HQkYp2NVoWvr/aTZkB8swOI5wHFbFkFXE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596185786568782.8852253163295; Fri, 31 Jul 2020 01:56:26 -0700 (PDT) Received: from localhost ([::1]:48514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1Qq1-0004cQ-Ba for importer@patchew.org; Fri, 31 Jul 2020 04:56:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1Qoy-0003O3-1U for qemu-devel@nongnu.org; Fri, 31 Jul 2020 04:55:20 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:56983 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k1Qow-0008Ag-Fc for qemu-devel@nongnu.org; Fri, 31 Jul 2020 04:55:19 -0400 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-84-3HMiOIe8PHam9N10d7Pycg-1; Fri, 31 Jul 2020 04:55:14 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E064418839C0; Fri, 31 Jul 2020 08:55:13 +0000 (UTC) Received: from localhost (ovpn-113-36.ams2.redhat.com [10.36.113.36]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3BB7F6179D; Fri, 31 Jul 2020 08:55:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596185717; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wu8Rc6eY4ey6WmkOwRjSnVil7pcllEVWfjJR7NyKsoM=; b=XGcrL+KSPc+Np9o67vaWNSWxD9DCthbGQVdtfppJA5zR5faDvJy7akWb614ZQt1ES/Z6eI e5zJLXSrMiP8xAwMtmNewX4He40qX48rNZmhhyxWgSMgYBc6jaQdY26ifYmNYbtxZrPEWb 1u4mmdlMPy+aZwdchWDFH8UMoG5ZP9U= X-MC-Unique: 3HMiOIe8PHam9N10d7Pycg-1 From: Cornelia Huck To: Peter Maydell Subject: [PULL 1/1] s390x/s390-virtio-ccw: fix off-by-one in loadparm getter Date: Fri, 31 Jul 2020 10:55:03 +0200 Message-Id: <20200731085503.9008-2-cohuck@redhat.com> In-Reply-To: <20200731085503.9008-1-cohuck@redhat.com> References: <20200731085503.9008-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=cohuck@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.61; envelope-from=cohuck@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/31 02:46:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Halil Pasic , qemu-s390x@nongnu.org, Cornelia Huck , qemu-devel@nongnu.org, David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Halil Pasic As pointed out by Peter, g_memdup(ms->loadparm, sizeof(ms->loadparm) + 1) reads one past of the end of ms->loadparm, so g_memdup() can not be used here. Let's use g_strndup instead! Fixes: d6645483285f ("s390x/s390-virtio-ccw: fix loadparm property getter") Fixes: Coverity CID 1431058 Reported-by: Peter Maydell Signed-off-by: Halil Pasic Reviewed-by: David Hildenbrand Reviewed-by: Peter Maydell Message-Id: <20200730130156.35063-1-pasic@linux.ibm.com> Signed-off-by: Cornelia Huck --- hw/s390x/s390-virtio-ccw.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 403d30e13bca..e72c61d2eae0 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -701,12 +701,9 @@ bool hpage_1m_allowed(void) static char *machine_get_loadparm(Object *obj, Error **errp) { S390CcwMachineState *ms =3D S390_CCW_MACHINE(obj); - char *loadparm_str; =20 /* make a NUL-terminated string */ - loadparm_str =3D g_memdup(ms->loadparm, sizeof(ms->loadparm) + 1); - loadparm_str[sizeof(ms->loadparm)] =3D 0; - return loadparm_str; + return g_strndup((char *) ms->loadparm, sizeof(ms->loadparm)); } =20 static void machine_set_loadparm(Object *obj, const char *val, Error **err= p) --=20 2.25.4