From nobody Sun May 19 02:06:38 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=1593414595; cv=none; d=zohomail.com; s=zohoarc; b=msjXI6FOrg6VGG4YBqzrHV0z+NW7EHl/BrqKFNQ7zooBM4xatcXlEkF94ujAMQNLoUuuELd9bbXV7fo2Qwf3loCdT1uQxVYYJOjgJijj7DBJ82l5PpNf0zQALTRruLv0RZy0W+pfkCYeDbWmQnJwrjja18QJ1MQrwN4ti8GssMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593414595; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=fawuTb1k2s1/RPCI2SKvzOHGJOjU32e1SGmkU6D2G4E=; b=I3XXS7SH2sZtDdm4b5y9ik9EWbJnxjVteatETpA+0g7mLk2ZSZv2S0UEt/czOTyUS6hQ4vLQCpTzkhYNy/TvrEoq/gKSE1ugmdxwLKfdX9peZNfEpO77ffFxqW3trgmenuwKhNSmXOKQd23x4kUBkaFKuIGQLVcTIw7rUqeZkhc= 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 1593414595889524.0403413171521; Mon, 29 Jun 2020 00:09:55 -0700 (PDT) Received: from localhost ([::1]:33760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpnvO-000487-Oq for importer@patchew.org; Mon, 29 Jun 2020 03:09:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpnuf-0003HU-Cq for qemu-devel@nongnu.org; Mon, 29 Jun 2020 03:09:09 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:25661 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 1jpnud-0008U8-Qk for qemu-devel@nongnu.org; Mon, 29 Jun 2020 03:09:09 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-163-WQ5jNGd5MEmqyzzVrc9EXw-1; Mon, 29 Jun 2020 03:09:03 -0400 Received: by mail-wm1-f72.google.com with SMTP id h6so18038537wmb.7 for ; Mon, 29 Jun 2020 00:09:02 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id d13sm36543580wrq.89.2020.06.29.00.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 00:09:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593414546; 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; bh=fawuTb1k2s1/RPCI2SKvzOHGJOjU32e1SGmkU6D2G4E=; b=Rw1oFaSLuKJ7WlSKzN9V3iJG5kn8/RnrgQso34g3IDNsp27ipiLeT29RberGkLwMWa/oYh pMGDVPiJdNogu1XBu1g+vph3qiV5r1NogthSIh9GqNUUgXUE3utALLJ3tQLrpT934Jfvkq pbs1Y4y7eyh0BPPBrBGS9sgaH8eKt9I= X-MC-Unique: WQ5jNGd5MEmqyzzVrc9EXw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fawuTb1k2s1/RPCI2SKvzOHGJOjU32e1SGmkU6D2G4E=; b=pUpiIWhz+6EwbT1Llar5gITjpZI8szehkm/fdoPCyBIlAWXQnXH/Ei1Lfe58pke6ua AfFDVIlinU2hboLHBkojAWA+j4bV8GIvQ7Jhzog5vj9vYyw3Nmxk41Ar1e8QVb7A0NAv k3iJL6PzcI0FE5iFAiE1pKi3264t4HKXW7EbTGjyU63Tk84U6xc+v9WtBxUBRImUt9eN dJcbWXMjB12hhyuiW0YOk0qg0rPsZqf/Ha0vaZt0ZiAtcqKAQ94K3kHKJndZJOT4Z2VF pGCTD5XSmZAOA1mltKFWfSc/xSFWTMu7yYujJWmW27OTMcA655jJ7rHK7ww+fnXS9O4x 44cg== X-Gm-Message-State: AOAM531AAMq8nV5dnNSam/gi7rtQuRZJK/qRAywPtbDBDiYjOymwp+Go eBlkn5o6fQXgQ9I1cHDe4ox9azIgL5yGGrjeBXHLxEHgKeR5PKvCSKoTTOF9AyNc9MjNrPSQ74t oLFBWJC7uxKIQSG8= X-Received: by 2002:a5d:68cc:: with SMTP id p12mr15461850wrw.111.1593414541792; Mon, 29 Jun 2020 00:09:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4/rBM6DXBzCq1M3jlss4KnuvLuDnvNCHFH4PY/VselrR3HFasK2K5gK50N60h+FGuXV5mhg== X-Received: by 2002:a5d:68cc:: with SMTP id p12mr15461824wrw.111.1593414541410; Mon, 29 Jun 2020 00:09:01 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2] util/qemu-option: Document the get_opt_value() function Date: Mon, 29 Jun 2020 09:08:58 +0200 Message-Id: <20200629070858.19850-1-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" 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=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/29 01:03:51 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.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, HEXHASH_WORD=1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: Damien Hedde , Kevin Wolf , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Coverity noticed commit 950c4e6c94 introduced a dereference before null check in get_opt_value (CID1391003): In get_opt_value: All paths that lead to this null pointer comparison already dereference the pointer earlier (CWE-476) We fixed this in commit 6e3ad3f0e31, but relaxed the check in commit 0c2f6e7ee99 because "No callers of get_opt_value() pass in a NULL for the 'value' parameter". Since this function is publicly exposed, it risks new users to do the same error again. Avoid that documenting the 'value' argument must not be NULL. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Daniel P. Berrang=C3=A9 --- v2: Drop confuse comment (Damien Hedde) --- include/qemu/option.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/qemu/option.h b/include/qemu/option.h index eb4097889d..ac50d25774 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -28,6 +28,19 @@ =20 #include "qemu/queue.h" =20 +/** + * get_opt_value + * @p: a pointer to the option name, delimited by commas + * @value: a non-NULL pointer that will received the delimited options + * + * The @value char pointer will be allocated and filled with + * the delimited options. + * + * Returns the position of the comma delimiter/zero byte after the + * option name in @p. + * The memory pointer in @value must be released with a call to g_free() + * when no longer required. + */ const char *get_opt_value(const char *p, char **value); =20 void parse_option_size(const char *name, const char *value, --=20 2.21.3