Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201111112500.GI1370092@port70.net>
Date: Wed, 11 Nov 2020 12:25:00 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: Alexey Izbyshev <izbyshev@...ras.ru>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH v2] MT fork

* Alexey Izbyshev <izbyshev@...ras.ru> [2020-11-11 09:35:22 +0300]:
> 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.
> > 

if we don't have to replicate a lot of code in ldso then this sounds good.

> > +static ssize_t read_loop(int fd, void *p, size_t n)
> > +{
> > +    unsigned char *b = p;
> > +    for (size_t l, i=0; i<n; i+=l) {
> > +        l = read(fd, b+i, n-i);
> > +        if (l<0) {
> > +            if (errno==EINTR) continue;
> This increments `i` by a negative `l`.

it's worse: l cannot be negative so the error check is ineffective.

maybe it should be ssize_t? or check == -1

> > +            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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.