]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Don't leave a stack marker linked in to the sbuff
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 29 Aug 2024 10:47:22 +0000 (05:47 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 29 Aug 2024 10:47:22 +0000 (05:47 -0500)
src/lib/util/sbuff.c

index 05fe57463b37d1cd71d215512c0458d6ab8b056d..06678c89fec0cf50a843349ee30141d12024bc23 100644 (file)
@@ -750,7 +750,10 @@ ssize_t fr_sbuff_out_bstrncpy_exact(fr_sbuff_t *out, fr_sbuff_t *in, size_t len)
                ssize_t copied;
 
                remaining = (len - fr_sbuff_used_total(&our_in));
-               if (remaining && !fr_sbuff_extend(&our_in)) return 0;
+               if (remaining && !fr_sbuff_extend(&our_in)) {
+                       fr_sbuff_marker_release(&m);
+                       return 0;
+               }
 
                chunk_len = fr_sbuff_remaining(&our_in);
                if (chunk_len > remaining) chunk_len = remaining;
@@ -763,6 +766,7 @@ ssize_t fr_sbuff_out_bstrncpy_exact(fr_sbuff_t *out, fr_sbuff_t *in, size_t len)
                        /* Amount remaining in input buffer minus the amount we could have copied */
                        if (len == SIZE_MAX) return -(fr_sbuff_remaining(in) - (chunk_len + copied));
                        /* Amount remaining to copy minus the amount we could have copied */
+                       fr_sbuff_marker_release(&m);
                        return -(remaining - (chunk_len + copied));
                }
                fr_sbuff_advance(&our_in, copied);