Message ID | 9e21220e872dc70dbcd8d4dcba38c3a607052d6e.1652435398.git.aclaudi@redhat.com (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Stephen Hemminger |
Headers | show |
Series | [iproute2] tipc: fix keylen check | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
diff --git a/tipc/misc.c b/tipc/misc.c index 909975d8..6175bf07 100644 --- a/tipc/misc.c +++ b/tipc/misc.c @@ -113,16 +113,15 @@ int str2key(char *str, struct tipc_aead_key *key) } } - if (len > TIPC_AEAD_KEYLEN_MAX) + key->keylen = ishex ? (len + 1) / 2 : len; + if (key->keylen > TIPC_AEAD_KEYLEN_MAX) return -1; /* Obtain key: */ if (!ishex) { - key->keylen = len; memcpy(key->key, str, len); } else { /* Convert hex string to key */ - key->keylen = (len + 1) / 2; for (i = 0; i < key->keylen; i++) { if (i == 0 && len % 2 != 0) { if (sscanf(str, "%1hhx", &key->key[0]) != 1)
Key length check in str2key() is wrong for hex. Fix this using the proper hex key length. Fixes: 28ee49e5153b ("tipc: bail out if key is abnormally long") Suggested-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: Andrea Claudi <aclaudi@redhat.com> --- tipc/misc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)