[PR #15196] Fix: Resolve incorrect GGUF magic validation in fs/gguf/gguf.go #61765

Open
opened 2026-04-29 16:47:09 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15196
Author: @hieuit095
Created: 4/1/2026
Status: 🔄 Open

Base: mainHead: fix/gguf-magic-validation


📝 Commits (1)

  • 8472594 Fix: Correct GGUF magic validation to use uppercase and proper logic

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 fs/gguf/gguf.go (+1 -1)

📄 Description

Summary

The GGUF magic validation in fs/gguf/gguf.go had two issues:

  1. Wrong case: The check compared against lowercase gguf but the actual GGUF magic is uppercase GGUF (ASCII: 0x47 0x47 0x55 0x46)
  2. Inverted logic: The check returned an error when magic equaled gguf, but it should return an error when magic does NOT equal the valid GGUF magic

Fix

Changed the condition to properly validate the GGUF magic:

  • Before: if bytes.Equal(f.Magic[:], []byte("gguf"))
  • After: if !bytes.Equal(f.Magic[:], []byte("GGUF"))

This ensures valid GGUF files are accepted and invalid/non-GGUF files are properly rejected.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/15196 **Author:** [@hieuit095](https://github.com/hieuit095) **Created:** 4/1/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/gguf-magic-validation` --- ### 📝 Commits (1) - [`8472594`](https://github.com/ollama/ollama/commit/84725946d7935020c64491f9d4edc92d82514fba) Fix: Correct GGUF magic validation to use uppercase and proper logic ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `fs/gguf/gguf.go` (+1 -1) </details> ### 📄 Description ## Summary The GGUF magic validation in `fs/gguf/gguf.go` had two issues: 1. **Wrong case**: The check compared against lowercase `gguf` but the actual GGUF magic is uppercase `GGUF` (ASCII: 0x47 0x47 0x55 0x46) 2. **Inverted logic**: The check returned an error when magic equaled `gguf`, but it should return an error when magic does NOT equal the valid `GGUF` magic ## Fix Changed the condition to properly validate the GGUF magic: - Before: `if bytes.Equal(f.Magic[:], []byte("gguf"))` - After: `if !bytes.Equal(f.Magic[:], []byte("GGUF"))` This ensures valid GGUF files are accepted and invalid/non-GGUF files are properly rejected. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-29 16:47:09 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#61765