[cpp-sp] branch main updated: Stop RNG generator at required byte length.

Codeberg noreply at shibboleth.net
Mon Sep 7 18:32:00 UTC 2026


This is an automated email from the git hooks/post-receive script.

codeberg pushed a commit to branch main
in repository cpp-sp.

View the commit online:
https://codeberg.org/Shibboleth/cpp-sp/commit/842e0ebc229151538c68bc768bb32ccee9f2f8be

The following commit(s) were added to refs/heads/main by this push:
     new 842e0ebc Stop RNG generator at required byte length.
842e0ebc is described below

commit 842e0ebc229151538c68bc768bb32ccee9f2f8be
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Mon Sep 7 14:31:49 2026 -0400

    Stop RNG generator at required byte length.
---
 shibsp/impl/AgentConfig.cpp | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/shibsp/impl/AgentConfig.cpp b/shibsp/impl/AgentConfig.cpp
index bc9432d5..e4737eab 100644
--- a/shibsp/impl/AgentConfig.cpp
+++ b/shibsp/impl/AgentConfig.cpp
@@ -166,20 +166,18 @@ Agent& AgentInternalConfig::getAgent() const
 
 string AgentInternalConfig::generateRandom(unsigned int len) const
 {
-    string s;
+    static size_t randlen = sizeof(uint_fast64_t);
 
+    string s;
     while (len > 0) {
         uint_fast64_t val = m_rng();
-        size_t randlen = sizeof(uint_fast64_t);
         for (int i = 0; i < randlen; ++i) {
             s += (char) (val & 0xFF);
+            if (--len == 0) {
+                break;
+            }
             val = val >> 8;
         }
-        if (len > randlen) {
-            len -= randlen;
-        } else {
-            len = 0;
-        }
     }
 
     return hex_encode(s);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list