From 5ba41ebd65c2b2369cd33dde79d786676d553e41 Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Mon, 11 Jul 2016 17:02:44 -0700 Subject: [PATCH] rdp: Check for non-digits and errno in strtol call Improve error checking for situations like RDP_FD=42foo, or where the provided number is out of range. Suggestion by Yong Bakos. Signed-off-by: Bryce Harrington Reviewed-by: Eric Engestrom Reviewed-by: Yong Bakos --- libweston/compositor-rdp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c index 79f06877..53c71248 100644 --- a/libweston/compositor-rdp.c +++ b/libweston/compositor-rdp.c @@ -1263,7 +1263,8 @@ rdp_backend_create(struct weston_compositor *compositor, } fd = strtoul(fd_str, &fd_tail, 10); - if (fd_tail == fd_str || rdp_peer_init(freerdp_peer_new(fd), b)) + if (errno != 0 || fd_tail == fd_str || *fd_tail != '\0' + || rdp_peer_init(freerdp_peer_new(fd), b)) goto err_output; }