scanner: Fail if 'since' is higher than the interface version
authorJonas Ådahl <jadahl@gmail.com>
Wed, 4 Nov 2015 06:21:52 +0000 (14:21 +0800)
committerJonas Ådahl <jadahl@gmail.com>
Tue, 12 Jan 2016 04:05:47 +0000 (12:05 +0800)
If an event or request have a "since" attribute that is larger than
the version of the interface it is in, fail with an explaining error
message.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
src/scanner.c

index 3f79a44..b00f036 100644 (file)
@@ -674,8 +674,12 @@ start_element(void *data, const char *element_name, const char **atts)
 
                if (since != NULL) {
                        version = strtouint(since);
-                       if (version == -1)
+                       if (version == -1) {
                                fail(&ctx->loc, "invalid integer (%s)\n", since);
+                       } else if (version > ctx->interface->version) {
+                               fail(&ctx->loc, "since (%u) larger than version (%u)\n",
+                                    version, ctx->interface->version);
+                       }
                } else {
                        version = 1;
                }