[PATCH] wayland-client: Require base 10 for WAYLAND_SOCKET, explicitly

Bryce Harrington bryce at osg.samsung.com
Sat Jul 9 02:00:47 UTC 2016


On Fri, Jul 08, 2016 at 06:36:19PM -0700, Yong Bakos wrote:
> On Jul 8, 2016, at 4:42 PM, Bryce Harrington <bryce at osg.samsung.com> wrote:
> > 
> > The third arg to strtol() specifies the base to assume for the number.
> > When 0 is passed, as is currently done in wayland-client.c, hexadecimal
> > and octal numbers are permitted and automatically detected and
> > converted.
> > 
> > I can find no indication that we would ever expect use of hexadecimal or
> > octal for socket fd's.  So be explicit about what base we're assuming
> > here and avoid any potential surprises.
> > 
> > Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
> 
> I can think of no drawbacks to this.
> 
> Reviewed-by: Yong Bakos <ybakos at humanoriented.com>

Thanks!
 
> Note that tests/exec-fd-leak-checker.c:40 also passes a 0 to strtol,
> and the usage (see main's 'help_out:') alludes to a decimal, the number
> of expected fd's. Might as well update that arg to 10 as well?

Yes, you're right.  I'm sending a separate patch for this fix.

Bryce

> Regards,
> yong
> 
> 
> > ---
> > src/wayland-client.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/src/wayland-client.c b/src/wayland-client.c
> > index 03c087a..3d7361e 100644
> > --- a/src/wayland-client.c
> > +++ b/src/wayland-client.c
> > @@ -1006,7 +1006,7 @@ wl_display_connect(const char *name)
> > 	if (connection) {
> > 		int prev_errno = errno;
> > 		errno = 0;
> > -		fd = strtol(connection, &end, 0);
> > +		fd = strtol(connection, &end, 10);
> > 		if (errno != 0 || connection == end || *end != '\0')
> > 			return NULL;
> > 		errno = prev_errno;
> > -- 
> > 1.9.1
> > 
> > _______________________________________________
> > wayland-devel mailing list
> > wayland-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list