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 3C6833858D39 for ; Thu, 16 Mar 2023 10:29:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3C6833858D39 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=1678962575; 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=gVontu83SQrcnbzkFSl4qcF8s9YoeL2IfQKfgnpU0Cc=; b=VTS8RXiMszlP6xCFuGNbdDXi7u1tSD8vYu5+g+rukWfy9KBnOZv372Cu3gDTuADdz6uc+B gmNNdJ3WeM4na7DryFFdF8mqqs/KC9Ojtj/D1nxt9OgHYV1xyeBvuBAoMwRFdrsnUb3Tyc wlALIJ7xL07wmLVphcMxu5V4YasdpGw= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-111-Pm0HzcpYPYilO0MsQebGFg-1; Thu, 16 Mar 2023 06:29:34 -0400 X-MC-Unique: Pm0HzcpYPYilO0MsQebGFg-1 Received: by mail-ed1-f69.google.com with SMTP id b7-20020a056402350700b004d2a3d5cd3fso2374136edd.8 for ; Thu, 16 Mar 2023 03:29:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678962573; h=content-transfer-encoding:in-reply-to:cc:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gVontu83SQrcnbzkFSl4qcF8s9YoeL2IfQKfgnpU0Cc=; b=pW69ykALAbi9KhbJ55KNiyZfyTv2k9KlVuQOmp0IP4HkTbpAl9zoaEH1zbg4QbHl7f YLFvpjEXaquMgULLPPUG/GlD5Nr/kxmFOxGcU0v//2vx5d6wM8LBtzQyZ2uQVd65dVR6 30Rab7RYCgDMDWEcZw+EAZR6N8y6iEVxhqNgMfP5e4mh+RKM58Z4Uv71sLvHSOvmt/AH xv66aQwQNpzAs6QI2+bZXNQRm2nF51BUUlCDkK1ZyN6Nxi7lKQiNvJzqSbqFDR/rKYcW ygJLF8T6CbkZGHx5kQRkaIOpITEAaVJgCEyNSlLQgDDlrrv2R4y1yKM/eD4lHF5MwXcZ Bwug== X-Gm-Message-State: AO0yUKXKl5q4ppvBQ1Lv98jcmzTu0f62eoKbhJsIaRaYQ8Sm5SmYNQmt K1MFd1Gfpc3uHCOaxtaQLXrVQz4C4Grnkd/gYD1jnjgy9z+X7eZtJSQW+Z7LSqzt9rHvAnuf43L h0FuPWoMnNHYWcAaWxIQwRze40iFP/AV24DCgIG9AC+lIUqjVtiJFyNHXCpyJriuBZRLP8ajc0i 6LSt+7jpk= X-Received: by 2002:a17:907:60c9:b0:8e1:12b6:a8fc with SMTP id hv9-20020a17090760c900b008e112b6a8fcmr11571952ejc.4.1678962572824; Thu, 16 Mar 2023 03:29:32 -0700 (PDT) X-Google-Smtp-Source: AK7set99p8bxKdNp4LMq/+ZdYwE35qmU+O+toL1VnpZ7ryVe3QOSWLPuzWq486sFC2LQeL8y/WdWgg== X-Received: by 2002:a17:907:60c9:b0:8e1:12b6:a8fc with SMTP id hv9-20020a17090760c900b008e112b6a8fcmr11571932ejc.4.1678962572493; Thu, 16 Mar 2023 03:29:32 -0700 (PDT) Received: from [192.168.188.47] (dynamic-077-001-129-153.77.1.pool.telefonica.de. [77.1.129.153]) by smtp.gmail.com with ESMTPSA id u17-20020a17090626d100b008c405ebc32esm3643277ejc.28.2023.03.16.03.29.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Mar 2023 03:29:31 -0700 (PDT) Message-ID: <92810b6e-e7e6-6ffd-d33a-067b9f300059@redhat.com> Date: Thu, 16 Mar 2023 11:29:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: UB status of snprintf on invalid ptr+size combination? To: libc-alpha@sourceware.org References: <20230315123949.GC73312@zira.vinc17.org> From: Stephan Bergmann Cc: Vincent Lefevre , Paul Eggert , Simon Chopin In-Reply-To: <20230315123949.GC73312@zira.vinc17.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 15/03/2023 13:39, Vincent Lefevre wrote: > No, it is not obvious. If the C standard does not say that this is > the size of the array, then it does not have to be the size of the > array. The C standard just says: > > Otherwise, output characters beyond the n-1st are discarded rather > than being written to the array, and a null character is written at > the end of the characters actually written into the array. But in 7.1.4 "Use of library functions" the standard also says > If a function argument is described as being an array, the pointer passed to the function shall > have a value such that all address computations and accesses to objects (that would be valid if > the pointer did point to the first element of such an array) are valid. which could be construed as meaning that the n-1st array element must always be accessible, even if a given invocation is known to always generate less then n output characters.