[PR #384] [MERGED] Fix random string generator #15348

Closed
opened 2025-11-02 11:44:34 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/384
Author: @denji
Created: 12/14/2016
Status: Merged
Merged: 12/20/2016
Merged by: @tboerger

Base: masterHead: badrandom


📝 Commits (2)

  • 9a742b5 Remove unused custom-alphabet feature of random string generator
  • 76afd53 Fixes variable (un)initialization mixed assign

📊 Changes

11 files changed (+94 additions, -35 deletions)

View changed files

📝 models/migrations/migrations.go (+6 -2)
📝 models/org.go (+6 -2)
📝 models/user.go (+7 -3)
📝 models/user_mail.go (+3 -1)
📝 modules/base/tool.go (+23 -9)
📝 modules/base/tool_test.go (+3 -1)
📝 routers/admin/users.go (+5 -1)
📝 routers/api/v1/admin/user.go (+5 -1)
📝 routers/install.go (+17 -11)
📝 routers/user/auth.go (+14 -3)
📝 routers/user/setting.go (+5 -1)

📄 Description

This PR fixes the following issues gogits/gogs#3953:

  • The random string generator was modulo-biased.
  • The random string generator silently ignored any errors returned by rand.Read. In the worst case, GetRandomString would simply return an empty string.

🔄 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/go-gitea/gitea/pull/384 **Author:** [@denji](https://github.com/denji) **Created:** 12/14/2016 **Status:** ✅ Merged **Merged:** 12/20/2016 **Merged by:** [@tboerger](https://github.com/tboerger) **Base:** `master` ← **Head:** `badrandom` --- ### 📝 Commits (2) - [`9a742b5`](https://github.com/go-gitea/gitea/commit/9a742b564379acb96091a25ee4a4007158b88277) Remove unused custom-alphabet feature of random string generator - [`76afd53`](https://github.com/go-gitea/gitea/commit/76afd53c06b71478481b8a2f88e17f0ba6cf775c) Fixes variable (un)initialization mixed assign ### 📊 Changes **11 files changed** (+94 additions, -35 deletions) <details> <summary>View changed files</summary> 📝 `models/migrations/migrations.go` (+6 -2) 📝 `models/org.go` (+6 -2) 📝 `models/user.go` (+7 -3) 📝 `models/user_mail.go` (+3 -1) 📝 `modules/base/tool.go` (+23 -9) 📝 `modules/base/tool_test.go` (+3 -1) 📝 `routers/admin/users.go` (+5 -1) 📝 `routers/api/v1/admin/user.go` (+5 -1) 📝 `routers/install.go` (+17 -11) 📝 `routers/user/auth.go` (+14 -3) 📝 `routers/user/setting.go` (+5 -1) </details> ### 📄 Description This PR fixes the following issues gogits/gogs#3953: * The random string generator was [modulo-biased](https://stackoverflow.com/a/10984975). * The random string generator silently ignored any errors returned by `rand.Read`. In the worst case, `GetRandomString` would simply return an empty string. --- <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 2025-11-02 11:44:34 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#15348