]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainSendKey: validate codeset argument
authorIlias Stamatis <stamatis.iliass@gmail.com>
Sat, 1 Jun 2019 12:40:12 +0000 (14:40 +0200)
committerErik Skultety <eskultet@redhat.com>
Tue, 4 Jun 2019 06:31:14 +0000 (08:31 +0200)
This argument wasn't validated anywhere, neither in the generic
implementation nor in the individual drivers. As a result a call to this
function with a large enough codeset value prior to this change causes
libvirtd to crash.

This happens because all drivers call virKeycodeValueTranslate which
uses codeset as an index to the virKeymapValues array, causing an
out-of-bounds error.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/libvirt-domain.c

index df7e405b3e3091c8ce1162ec632a1f06005bde5c..509ce5ac8b5970668b9822a1785dae95bfc184cc 100644 (file)
@@ -6837,6 +6837,13 @@ virDomainSendKey(virDomainPtr domain,
     virCheckNonNullArgGoto(keycodes, error);
     virCheckPositiveArgGoto(nkeycodes, error);
 
+    if (codeset >= VIR_KEYCODE_SET_LAST) {
+        virReportInvalidArg(codeset,
+                            _("Unsupported codeset '%d'"),
+                            codeset);
+        goto error;
+    }
+
     if (nkeycodes > VIR_DOMAIN_SEND_KEY_MAX_KEYS) {
         virReportInvalidArg(nkeycodes,
                             _("nkeycodes must be <= %d"),