From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 26875 invoked from network); 29 Jul 2022 19:40:11 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 29 Jul 2022 19:40:11 -0000 Received: (qmail 3821 invoked by uid 550); 29 Jul 2022 19:40:08 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 3775 invoked from network); 29 Jul 2022 19:40:07 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=W8g0BTAQHF0AD3B0NhFPKr0E2VWfgJh+Pb0qxfSI9uk=; b=PdtzbhEGmjQRp0atbZY14w5De1g4bDJO5M4um2HjS57Hi1ExMhGjqdgJXKpe16aW6s XnMJ4zCY6Q/z6WqdW6knnNSNES3qUHuM19nWxLnkIeyJVwJm+b2HSOA+mOGxdz6SCYsd 1ne4XKTFoDsWkEOwR+5gf7OcK5ijK2uvUBh9QbAhAN3HaVN11Yp+nC+iVpu/nt4wZjHL 14fLMpv8wflc1yVJtu33VHzyGVlIF/ptM0sIGy3VsvvPfud38xs5jMBv9KCCnWTAivWU qC9UO6BGgueliMJkhZEE24BKgytOMtyBhkWI9HEq2an7/AKODwzJx/FGjRfr2SJD9ewY ApaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=W8g0BTAQHF0AD3B0NhFPKr0E2VWfgJh+Pb0qxfSI9uk=; b=Ft4wp4AzKJe+pfnrKMNQ2Nw61C0pd8ZisRn/kv9vIPuJxInTSbyMlfBOpHXjwdnTZw PIh/WsHti1p47C32GQcRLq2oUI7hFSX175sC+O4bm4G8/MqEbm/NEI6/Lbyv4FUO95cW Pt3RhpGSkW+aTyFu5qvjuo2PFOAkyHmjozWuIk0GSM81aqn1MblkI+SlmucON2f8hDMG MTK/vuQMx+A4rGnf2SlovfYwOTswYwchGYfEWKhzh9bFJpXOWtOQpy0Q/SB3gA6XzGNB /ohIUiXQ6ksi8Z86iemBwPzo4ELM3EQ1au1fLJi4dEoUU7Lj/JPC2D5boGQaF/uzVmDg PYMA== X-Gm-Message-State: AJIora+ddTL4yZd36X4+InBTY3/Guzvye9CjCxOX2609vXKgIqn2V2u5 344CzGlFwEdahxuHEH9XiTVpasnQ7Ohw8wI3xweXZZBWEgBvFQ== X-Google-Smtp-Source: AGRyM1stsPf9TkBPcGLJY1dexNiqH5Z7m9rajJUMMoF5FiBjsrRAJqSd3sBL5njTWX51GoSt8o59IE0ob77oD0OsVuc= X-Received: by 2002:a05:651c:b12:b0:25e:2738:5423 with SMTP id b18-20020a05651c0b1200b0025e27385423mr1594197ljr.349.1659123595323; Fri, 29 Jul 2022 12:39:55 -0700 (PDT) MIME-Version: 1.0 References: <43e9ad2b-d53c-5fd5-0211-766f946c90f9@landley.net> <48546934-5ccd-0b1e-bf2b-306133101c6b@landley.net> <20220727175859.GC1320090@port70.net> <652507478.86440.1658957388428.JavaMail.zimbra@efficios.com> <20220729185357.yifwo5wlkyh33dj3@gen2.localdomain> In-Reply-To: <20220729185357.yifwo5wlkyh33dj3@gen2.localdomain> From: enh Date: Fri, 29 Jul 2022 12:39:43 -0700 Message-ID: To: musl@lists.openwall.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [musl] Re: sysconf(_SC_NPROCESSORS_CONF) broken. On Fri, Jul 29, 2022 at 11:53 AM NRK wrote: > > On Fri, Jul 29, 2022 at 11:42:19AM -0700, enh wrote: > > done: https://android-review.googlesource.com/c/platform/bionic/+/2168844 > > if (getline(&line, &allocated_size, fp) != -1) { > cpu_count = GetCpuCountFromString(line); > free(line); > } > > Shouldn't the buffer be `free`-ed regardless or weather getline fails or > not? The getline(3) manpage suggests so: yeah, i almost changed that in passing (because i worried that someone would copy & paste for a loop, where you don't want to free() on every iteration) but assumed (incorrectly!) that earlier me had checked. fixed now, thanks: https://android-review.googlesource.com/c/platform/bionic/+/2170542 > > If *lineptr is set to NULL before the call, then getline() will > > allocate a buffer for storing the line. This buffer should be freed by > > the user program even if getline() failed. it looks like it's not entirely theoretical either --- a quick look at bionic's [OpenBSD] getdelim() implementation shows that it can return failure on the first call but leaving buf non-null (you'd need the first allocation to succeed, and need a second allocation that fails; which -- along with the fact -- is probably why i don't remember ever seeing this in practice). i'll send a patch to man7.org to mention this in the ERRORS section, because i didn't see it up top when i looked before getting to the part of your mail with a ctrl-f'able quote :-) > - NRK