[PATCH weston] multi-resource: Check for no digits in time description

Bryce Harrington bryce at osg.samsung.com
Sat Jul 9 01:35:05 UTC 2016


strtoul(nptr, endptr, ...) will set *endptr to nptr in the case of where
no digits were read from the string.  E.g. "foo:bar" should trigger an
error, instead of being read as "0:0" and allowed through.

Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
---
 clients/multi-resource.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/clients/multi-resource.c b/clients/multi-resource.c
index c283022..2fca7c3 100644
--- a/clients/multi-resource.c
+++ b/clients/multi-resource.c
@@ -434,12 +434,13 @@ create_device(struct display *display, const char *time_desc, int type)
 
 	errno = 0;
 	start_time = strtoul(time_desc, &tail, 10);
-	if (errno)
+	if (errno || tail == time_desc)
 		goto error;
 
 	if (*tail == ':') {
-		end_time = strtoul(tail + 1, &tail, 10);
-		if (errno || *tail != '\0')
+		time_desc = tail + 1;
+		end_time = strtoul(time_desc, &tail, 10);
+		if (errno || tail == time_desc || *tail != '\0')
 			goto error;
 	} else if (*tail != '\0') {
 		goto error;
-- 
1.9.1



More information about the wayland-devel mailing list