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=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 26719 invoked from network); 11 Nov 2020 06:35:40 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 11 Nov 2020 06:35:40 -0000 Received: (qmail 20060 invoked by uid 550); 11 Nov 2020 06:35:34 -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 20042 invoked from network); 11 Nov 2020 06:35:34 -0000 MIME-Version: 1.0 Date: Wed, 11 Nov 2020 09:35:22 +0300 From: Alexey Izbyshev To: musl@lists.openwall.com In-Reply-To: <20201111005216.GH534@brightrain.aerifal.cx> References: <20201027211735.GV534@brightrain.aerifal.cx> <20201030185205.GA10849@arya.arvanta.net> <20201030185716.GE534@brightrain.aerifal.cx> <5298816.XTEcGr0bgB@nanabozho> <20201031033117.GH534@brightrain.aerifal.cx> <20201106033616.GX534@brightrain.aerifal.cx> <20201108161215.GE1370092@port70.net> <20201109170729.GA534@brightrain.aerifal.cx> <20201109215901.GG1370092@port70.net> <20201109222320.GC534@brightrain.aerifal.cx> <20201111005216.GH534@brightrain.aerifal.cx> User-Agent: Roundcube Webmail/1.4.4 Message-ID: X-Sender: izbyshev@ispras.ru Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [musl] [PATCH v2] MT fork On 2020-11-11 03:52, Rich Felker wrote: > Here's a proposed first patch in series, getting rid of getdelim/stdio > usage in ldso. I think that suffices to set the stage for adding > __libc_malloc, __libc_free, __libc_calloc, __libc_realloc and having > ldso use them. > > +static ssize_t read_loop(int fd, void *p, size_t n) > +{ > + unsigned char *b = p; > + for (size_t l, i=0; i + l = read(fd, b+i, n-i); > + if (l<0) { > + if (errno==EINTR) continue; This increments `i` by a negative `l`. > + else return -1; > + } > + if (l==0) return i; > + } > + return n; > +} > + if (fd>=0) { > + size_t n = 0; > + if (!fstat(fd, &st)) n = st.st_size; > + sys_path = malloc(n+1); > + sys_path[n] = 0; `sys_path` can be NULL here. > + if (!sys_path || read_loop(fd, sys_path, n)<0) { > free(sys_path); > sys_path = ""; > } > - fclose(f); > + close(fd); > } else if (errno != ENOENT) { > sys_path = ""; > } Alexey