[PR #9952] fix: validate input size in parseSafetensors to prevent integer overflow #75400

Open
opened 2026-05-05 07:49:46 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/9952
Author: @y198nt
Created: 3/23/2025
Status: 🔄 Open

Base: mainHead: patch-1


📝 Commits (1)

  • e565970 fix: validate input size in parseSafetensors to prevent integer overflow

📊 Changes

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

View changed files

📝 convert/reader_safetensors.go (+5 -0)

📄 Description

Added validation for the n variable in the parseSafetensors function to ensure it is within a safe and reasonable range. This prevents potential integer overflow or excessive memory allocation issues that could lead to a panic. Updated error handling to provide clearer messages for invalid or excessive sizes.


🔄 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/9952 **Author:** [@y198nt](https://github.com/y198nt) **Created:** 3/23/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `patch-1` --- ### 📝 Commits (1) - [`e565970`](https://github.com/ollama/ollama/commit/e565970a204cb44bdfd69ea32a6e03c257b7a33b) fix: validate input size in parseSafetensors to prevent integer overflow ### 📊 Changes **1 file changed** (+5 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `convert/reader_safetensors.go` (+5 -0) </details> ### 📄 Description Added validation for the `n` variable in the `parseSafetensors` function to ensure it is within a safe and reasonable range. This prevents potential integer overflow or excessive memory allocation issues that could lead to a panic. Updated error handling to provide clearer messages for invalid or excessive sizes. --- <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-05-05 07:49:46 -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#75400