From c2e7727f4689230e806272b830db251ffd4d210e Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Mon, 10 Oct 2016 15:25:33 +0200 Subject: [PATCH] usb: add range check to UTF-16 string copy --- repos/os/include/usb/types.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/repos/os/include/usb/types.h b/repos/os/include/usb/types.h index 28ce656c32..dc95be31b2 100644 --- a/repos/os/include/usb/types.h +++ b/repos/os/include/usb/types.h @@ -73,6 +73,10 @@ struct Usb::String void copy(unsigned len, void *from, Genode::Allocator *md_alloc) { length = len; + + if (len == 0) + return; + string = (utf16_t *)md_alloc->alloc(length * sizeof(utf16_t)); Genode::memcpy(string, from, sizeof(utf16_t) * length); }