Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gguf : opening an invalid file may cause a out of bounds access #614

Closed
slaren opened this issue Nov 16, 2023 · 0 comments
Closed

gguf : opening an invalid file may cause a out of bounds access #614

slaren opened this issue Nov 16, 2023 · 0 comments

Comments

@slaren
Copy link
Collaborator

slaren commented Nov 16, 2023

It is not guaranteed that magic is NUL terminated, but it is printed as a string:

ggml/src/ggml.c

Lines 18025 to 18038 in cce2ac9

char magic[4];
// check the magic before making allocations
{
gguf_fread_el(file, &magic, sizeof(magic), &offset);
for (uint32_t i = 0; i < sizeof(magic); i++) {
if (magic[i] != GGUF_MAGIC[i]) {
fprintf(stderr, "%s: invalid magic characters %s.\n", __func__, magic);
fclose(file);
return NULL;
}
}
}

@slaren slaren changed the title gguf : opening an invalid file may cause a buffer overflow gguf : opening an invalid file may cause a out of bounds access Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant