From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id A01093858401 for ; Thu, 24 Aug 2023 14:39:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A01093858401 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692887955; 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=nrW4e+3ON3lb5Xe/C1HogOGvHbHNBbXwBcUO2GWtlG8=; b=FS6qJ8Mp4eOUm3+5JRJKGXVetbFB3X4f6h2plFsLAi2lv1iHptTEVDbFtV5M1a/T7chcTz WuCR0XqLmy2+YoKc+qLYFpRtZ0o6+WnCRVa7h4FlcP3CVmL6RgA/qrJ/ua5Hmzh9OfnEzK c35V3GUJxV9GzEbSb1AVihm9LAiNNMQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-539-QkwoSXqvMACIgzzGzzCx5Q-1; Thu, 24 Aug 2023 10:39:13 -0400 X-MC-Unique: QkwoSXqvMACIgzzGzzCx5Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D4A6780557A for ; Thu, 24 Aug 2023 14:39:07 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.22.32.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF65D40C6F4C; Thu, 24 Aug 2023 14:39:07 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 8/9] analyzer: handle strlen(BITS_WITHIN) [PR105899] Date: Thu, 24 Aug 2023 10:39:02 -0400 Message-Id: <20230824143903.3161185-9-dmalcolm@redhat.com> In-Reply-To: <20230824143903.3161185-1-dmalcolm@redhat.com> References: <20230824143903.3161185-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: gcc/analyzer/ChangeLog: PR analyzer/105899 * region-model.cc (fragment::has_null_terminator): Handle SK_BITS_WITHIN. --- gcc/analyzer/region-model.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index 6574ec140074..025b555d7b97 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -3357,10 +3357,29 @@ struct fragment } break; + case SK_BITS_WITHIN: + { + const bits_within_svalue *bits_within_sval + = (const bits_within_svalue *)m_sval; + byte_range bytes (0, 0); + if (bits_within_sval->get_bits ().as_byte_range (&bytes)) + { + const svalue *inner_sval = bits_within_sval->get_inner_svalue (); + fragment f (byte_range + (start_read_offset - bytes.get_start_bit_offset (), + std::max (bytes.m_size_in_bytes, + available_bytes)), + inner_sval); + return f.has_null_terminator (start_read_offset, out_bytes_read); + } + } + break; + default: // TODO: it may be possible to handle other cases here. - return tristate::TS_UNKNOWN; + break; } + return tristate::TS_UNKNOWN; } static tristate -- 2.26.3