]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
X.509: fix buffer overflow detection in sprint_oid()
authorEric Biggers <ebiggers@google.com>
Fri, 8 Dec 2017 15:13:28 +0000 (15:13 +0000)
committerDavid Howells <dhowells@redhat.com>
Fri, 8 Dec 2017 15:13:28 +0000 (15:13 +0000)
commit47e0a208fb9d91e3f3c86309e752b13a36470ae8
tree7ef7646ed93f622533c61b0290fecb43cec8853e
parent0f30cbea005bd3077bd98cd29277d7fc2699c1da
X.509: fix buffer overflow detection in sprint_oid()

In sprint_oid(), if the input buffer were to be more than 1 byte too
small for the first snprintf(), 'bufsize' would underflow, causing a
buffer overflow when printing the remainder of the OID.

Fortunately this cannot actually happen currently, because no users pass
in a buffer that can be too small for the first snprintf().

Regardless, fix it by checking the snprintf() return value correctly.

For consistency also tweak the second snprintf() check to look the same.

Fixes: 4f73175d0375 ("X.509: Add utility functions to render OIDs as strings")
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: James Morris <james.l.morris@oracle.com>
lib/oid_registry.c