Re: libc: simplify devname() fallback

2016-07-05 Thread Todd C. Miller
On Mon, 04 Jul 2016 22:24:02 -0700, Philip Guenther wrote: > Yep. Too much programming in a garbage collected language recently, I > guess. :-) > > Revised diff below. OK millert@ - todd

Re: libc: simplify devname() fallback

2016-07-04 Thread Philip Guenther
On Wed, 29 Jun 2016, Todd C. Miller wrote: > On Wed, 29 Jun 2016 07:05:15 -0600, "Todd C. Miller" wrote: > > Don't you need to make a copy of dp->d_name? Returning dp->d_name > > after closedir() seems dangerous. > > Since closedir() frees dd_buf this would result in a user after free. Yep. Too

Re: libc: simplify devname() fallback

2016-07-04 Thread Philip Guenther
On Wed, 29 Jun 2016, Marc Espie wrote: > On Tue, Jun 28, 2016 at 09:46:30PM -0700, Philip Guenther wrote: > > Inspired by espie@'s ttyname.c diff, here's a simplification of libc's > > fallback-to-scanning-/dev code for devname(). Since devname() returns > > the "name under /dev", this eliminate

Re: libc: simplify devname() fallback

2016-06-29 Thread Todd C. Miller
On Wed, 29 Jun 2016 07:05:15 -0600, "Todd C. Miller" wrote: > Don't you need to make a copy of dp->d_name? Returning dp->d_name > after closedir() seems dangerous. Since closedir() frees dd_buf this would result in a user after free. - todd

Re: libc: simplify devname() fallback

2016-06-29 Thread Todd C. Miller
On Tue, 28 Jun 2016 21:46:30 -0700, Philip Guenther wrote: > Inspired by espie@'s ttyname.c diff, here's a simplification of libc's > fallback-to-scanning-/dev code for devname(). Since devname() returns > the "name under /dev", this eliminates the string manipulation == win! > > Works when test

Re: libc: simplify devname() fallback

2016-06-29 Thread Marc Espie
On Tue, Jun 28, 2016 at 09:46:30PM -0700, Philip Guenther wrote: > Inspired by espie@'s ttyname.c diff, here's a simplification of libc's > fallback-to-scanning-/dev code for devname(). Since devname() returns > the "name under /dev", this eliminates the string manipulation == win! > > Works when

libc: simplify devname() fallback

2016-06-28 Thread Philip Guenther
Inspired by espie@'s ttyname.c diff, here's a simplification of libc's fallback-to-scanning-/dev code for devname(). Since devname() returns the "name under /dev", this eliminates the string manipulation == win! Works when tested with "stat -Lf %Sr" on a symlink to a device with /var/run/dev.db c