]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Stupid static analysis?
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 17 Jul 2018 20:04:20 +0000 (16:04 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 17 Jul 2018 20:04:20 +0000 (16:04 -0400)
src/lib/server/state.c

index d0532b111b9fbb6ed1c20ddedd5c122741105913..8d3e4bf86f2ce248d64f6de21e28d4a3f12f8da8 100644 (file)
@@ -428,17 +428,17 @@ static fr_state_entry_t *state_entry_create(fr_state_tree_t *state, REQUEST *req
                 *      16 octets of randomness should be enough to
                 *      have a globally unique state.
                 */
-               if (!old) {
-                       for (i = 0; i < sizeof(entry->state) / sizeof(x); i++) {
-                               x = fr_rand();
-                               memcpy(entry->state + (i * 4), &x, sizeof(x));
-                       }
+               if (old) {
+                       memcpy(entry->state, old_state, sizeof(entry->state));
+                       entry->tries = old_tries + 1;
                /*
                 *      Base the new state on the old state if we had one.
                 */
                } else {
-                       memcpy(entry->state, old_state, sizeof(entry->state));
-                       entry->tries = old_tries + 1;
+                       for (i = 0; i < sizeof(entry->state) / sizeof(x); i++) {
+                               x = fr_rand();
+                               memcpy(entry->state + (i * 4), &x, sizeof(x));
+                       }
                }
 
                entry->state_comp.tries = entry->tries + 1;