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 <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
This commit is contained in:
Bryce Harrington 2016-07-11 17:02:44 -07:00
parent 7fc000c826
commit 5ba41ebd65
1 changed files with 2 additions and 1 deletions

View File

@ -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;
}