mirror of
https://github.com/ggml-org/whisper.cpp.git
synced 2026-10-04 05:21:27 +02:00
whisper,parakeet : reject invalid n_dims in tensor header to prevent stack-buffer-overflow on malformed model files (#3957)
* fix: reject invalid n_dims in tensor header to prevent stack-buffer-overflow on malformed model files * Validate n_dims value in model file loading Add error handling for invalid n_dims in model file.
This commit is contained in:
@@ -1439,6 +1439,11 @@ static bool parakeet_model_load(struct parakeet_model_loader * loader, parakeet_
|
||||
break;
|
||||
}
|
||||
|
||||
if (n_dims < 0 || n_dims > 4) {
|
||||
PARAKEET_LOG_ERROR("%s: invalid n_dims %d in model file (expected 0 <= n_dims <= 4)\n", __func__, n_dims);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t nelements = 1;
|
||||
int32_t ne[4] = { 1, 1, 1, 1 };
|
||||
for (int i = 0; i < n_dims; ++i) {
|
||||
|
||||
Reference in New Issue
Block a user