Fix off-by-one in blob download, where in the case that the blob is evenly
authorpatrick <patrick@openbsd.org>
Mon, 27 Dec 2021 14:31:15 +0000 (14:31 +0000)
committerpatrick <patrick@openbsd.org>
Mon, 27 Dec 2021 14:31:15 +0000 (14:31 +0000)
divisible by 1400, the last chunk isn't marked with an end flag.

ok tobhe@

sys/dev/ic/bwfm.c

index 8b08d4c..23c3bb5 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: bwfm.c,v 1.96 2021/12/27 14:28:13 patrick Exp $ */
+/* $OpenBSD: bwfm.c,v 1.97 2021/12/27 14:31:15 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
  * Copyright (c) 2016,2017 Patrick Wildt <patrick@blueri.se>
@@ -2993,7 +2993,7 @@ bwfm_process_blob(struct bwfm_softc *sc, char *var, u_char **blob,
                data->flag = htole16(BWFM_DLOAD_FLAG_HANDLER_VER_1);
                if (off == 0)
                        data->flag |= htole16(BWFM_DLOAD_FLAG_BEGIN);
-               if (remain < BWFM_DLOAD_MAX_LEN)
+               if (remain <= BWFM_DLOAD_MAX_LEN)
                        data->flag |= htole16(BWFM_DLOAD_FLAG_END);
                data->type = htole16(BWFM_DLOAD_TYPE_CLM);
                data->len = htole32(len);