Re: ldd: check read return value to avoid unitialized struct fields

2023-08-11 Thread Lucas
Greg Steuck wrote: > Thanks for the patch. > > I could see some value in tightening the conditions to always check > `!= expected`. I don't see enough improvement from separating the error > case of -1 from the incomplete read case considering the otherwise > identical behavior. Like this? The i

Re: ldd: check read return value to avoid unitialized struct fields

2023-08-10 Thread Theo de Raadt
Greg Steuck wrote: > Thanks for the patch. > > I could see some value in tightening the conditions to always check > `!= expected`. I don't see enough improvement from separating the error > case of -1 from the incomplete read case considering the otherwise > identical behavior. Hmm, that is a

Re: ldd: check read return value to avoid unitialized struct fields

2023-08-10 Thread Lucas
Greg Steuck wrote: > Thanks for the patch. > > I could see some value in tightening the conditions to always check > `!= expected`. I don't see enough improvement from separating the error > case of -1 from the incomplete read case considering the otherwise > identical behavior. I'll refer to ht

Re: ldd: check read return value to avoid unitialized struct fields

2023-08-10 Thread Greg Steuck
Thanks for the patch. I could see some value in tightening the conditions to always check `!= expected`. I don't see enough improvement from separating the error case of -1 from the incomplete read case considering the otherwise identical behavior. Lucas writes: > Bump. > >

Re: ldd: check read return value to avoid unitialized struct fields

2023-08-10 Thread Lucas
Bump. --- commit 92f58b2a1cd576c3e72303004388ab1e9709e327 (ldd-read-rv) from: Lucas date: Sat Aug 5 16:34:16 2023 UTC Check {,p}read return values consistently Check that read performs a full header read. Explicitly check against -1 for failure

Re: ldd: check read return value to avoid unitialized struct fields

2023-08-05 Thread Theo de Raadt
That looks better. Lucas wrote: > Theo Buehler wrote: > > > - if (pread(fd, phdr, size, ehdr.e_phoff) != size) { > > > + if ((nr = pread(fd, phdr, size, ehdr.e_phoff)) != -1) { > > > > did you intend to check for == -1? > > > > > warn("read(%s)", name); > > > > should that not say

Re: ldd: check read return value to avoid unitialized struct fields

2023-08-05 Thread Lucas
Theo Buehler wrote: > > - if (pread(fd, phdr, size, ehdr.e_phoff) != size) { > > + if ((nr = pread(fd, phdr, size, ehdr.e_phoff)) != -1) { > > did you intend to check for == -1? > > > warn("read(%s)", name); > > should that not say pread? Indeed, thanks for spotting both things

Re: ldd: check read return value to avoid unitialized struct fields

2023-08-05 Thread Theo Buehler
> - if (pread(fd, phdr, size, ehdr.e_phoff) != size) { > + if ((nr = pread(fd, phdr, size, ehdr.e_phoff)) != -1) { did you intend to check for == -1? > warn("read(%s)", name); should that not say pread?

Re: ldd: check read return value to avoid unitialized struct fields

2023-08-05 Thread Lucas
"Theo de Raadt" wrote: > Nope, that is not correct. > > errno is not being cleared. It just happens to be zero. Future > code changes could insert another operation above which would set > errno, and then this would print a report about that error. Although I was being sarcastic with """Everyt

Re: ldd: check read return value to avoid unitialized struct fields

2023-08-05 Thread Theo de Raadt
Lucas wrote: > "Theo de Raadt" wrote: > > What errno is being printed here? > > """Everything is alright""" error, > > $ : >empty && ./obj/ldd empty > ldd: read(empty): Undefined error: 0 > > which would be the same as a short read in the pread below. Nope, that is not correct.

Re: ldd: check read return value to avoid unitialized struct fields

2023-08-05 Thread Lucas
"Theo de Raadt" wrote: > What errno is being printed here? """Everything is alright""" error, $ : >empty && ./obj/ldd empty ldd: read(empty): Undefined error: 0 which would be the same as a short read in the pread below. Bigger suggestion below, addressing both read and pread.

Re: ldd: check read return value to avoid unitialized struct fields [was "ldd: check {,p}read return

2023-08-04 Thread Theo de Raadt
Lucas wrote: > Bump. > > Lucas wrote: > > Now with a better subject. > > > > I was also wondering about the lack of pledge() other than the newly > > added one. That goes because dlopen() can do anything? > > > > Lucas wrote: > > > Hi, > > > > > > I wanted to understand how the pledge execp

Re: ldd: check read return value to avoid unitialized struct fields [was "ldd: check {,p}read return

2023-08-04 Thread Lucas
Bump. Lucas wrote: > Now with a better subject. > > I was also wondering about the lack of pledge() other than the newly > added one. That goes because dlopen() can do anything? > > Lucas wrote: > > Hi, > > > > I wanted to understand how the pledge execpromises commit worked in ldd > > and we

ldd: check read return value to avoid unitialized struct fields [was "ldd: check {,p}read return value consistently"]

2023-07-29 Thread Lucas
Now with a better subject. I was also wondering about the lack of pledge() other than the newly added one. That goes because dlopen() can do anything? Lucas wrote: > Hi, > > I wanted to understand how the pledge execpromises commit worked in ldd > and went to read it, and noticed that there is