From: anton Date: Tue, 31 Aug 2021 05:16:45 +0000 (+0000) Subject: Protect against missing bit to key symbols in ucc_bit_to_sym(). This can X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=087025f8fbdd9151b05a36c2345a6b513fd0a50f;p=openbsd Protect against missing bit to key symbols in ucc_bit_to_sym(). This can only happen if ucc_hid_parse() has a bug, better play it safe. --- diff --git a/sys/dev/usb/ucc.c b/sys/dev/usb/ucc.c index 96bfcc1518b..39e588dee76 100644 --- a/sys/dev/usb/ucc.c +++ b/sys/dev/usb/ucc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ucc.c,v 1.19 2021/08/29 19:00:59 anton Exp $ */ +/* $OpenBSD: ucc.c,v 1.20 2021/08/31 05:16:45 anton Exp $ */ /* * Copyright (c) 2021 Anton Lindqvist @@ -1003,7 +1003,7 @@ ucc_add_key(struct ucc_softc *sc, int32_t usage, u_int bit) int ucc_bit_to_sym(struct ucc_softc *sc, u_int bit, const struct ucc_keysym **us) { - if (bit >= sc->sc_rawsiz) + if (bit >= sc->sc_rawsiz || sc->sc_raw[bit] == NULL) return 1; *us = sc->sc_raw[bit]; return 0;