Commit c81682975d46030365da4e6c529f547a71014cee

Peter Hutterer 2018-08-01T18:47:24

action: make a note that we may not null-terminate private strings Coverity complains that a 7-byte string may not be null-terminated when copied into act->data (size 7). This is fine, make a note of it. All the strings in xkeyboard-config only use 6 bytes + null terminator so this won't be an issue. The server (the only user of these) uses an 8-byte array and forcibly null-terminates the string, see XkbDDXPrivate(). Everything else treats it as byte-array size 7 anyway so whether it's null-terminated doesn't matter. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

1
2
3
4
5
6
7
8
9
10
11
12
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index 5f1fd65..f99a850 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -705,6 +705,7 @@ HandlePrivate(struct xkb_context *ctx, const struct xkb_mod_set *mods,
                 return false;
             }
 
+            /* act->data may not be null-terminated, this is intentional */
             strncpy((char *) act->data, str, sizeof(act->data));
             return true;
         }