Sfoglia il codice sorgente

wasi_nn_openvino.c: add a missing buffer overflow check in get_output (#4353)

cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4351
YAMAMOTO Takashi 7 mesi fa
parent
commit
2f0750a6fe
1 ha cambiato i file con 5 aggiunte e 0 eliminazioni
  1. 5 0
      core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c

+ 5 - 0
core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c

@@ -439,6 +439,11 @@ get_output(void *ctx, graph_execution_context exec_ctx, uint32_t index,
 
     CHECK_OV_STATUS(ov_tensor_get_byte_size(ov_tensor, &byte_size), ret);
 
+    if (byte_size > *output_tensor_size) {
+        ret = too_large;
+        goto fail;
+    }
+
     CHECK_OV_STATUS(ov_tensor_data(ov_tensor, &data), ret);
 
     memcpy(output_tensor, data, byte_size);