]> git.ozlabs.org Git - ccan/commitdiff
stringbuilder: avoid overwriting end of buffer with nul terminator.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 9 Jan 2023 02:22:22 +0000 (12:52 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 16 Mar 2023 23:22:47 +0000 (09:52 +1030)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/stringbuilder/stringbuilder.c

index d34de811b3542dbea10610f875f554dc4e734085..8eb4ab42fc812d32f5b0bb99c2b31e82fc0b90b2 100644 (file)
@@ -22,7 +22,8 @@ static int stringbuilder_cpy(
        if (*str != s) {
                if (!s_len)
                        s_len = strlen(s);
-               if (s_len > *str_sz)
+               /* Include nul term! */
+               if (s_len >= *str_sz)
                        return EMSGSIZE;
                strcpy(*str, s);
        }