Comment 3 for bug 1951834

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

> specified bound depends on the length of the source argument [-Wstringop-truncation]

I believe the strncpy warning can be ignored because the buffer was reallocated using that size just before:

static void str_append(char **buf, const char *repr)
{
    if (*buf) {
        *buf = realloc(*buf, strlen(*buf) + strlen(repr) + 1);
        assert(*buf);
        strncpy((*buf) + strlen(*buf), repr, strlen(repr) + 1);
    } else {
        *buf = strdup(repr);
        assert(*buf);
    }
}

And we are copying into the middle of the reallocated buffer, not its start. Furthermore, this is test code.