X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=lib%2Fseq_buf.c;h=6aabb609dd87196778b4b4a399e3cd01067e656a;hb=3f35cd2c656116f30cef95c8f489cebde048a0ab;hp=11f2ae0f90996ac0463ae712785c0135e3576fb8;hpb=a3841f94c7ecb3ede0f888d3fcfe8fb6368ddd7a;p=mirror_ubuntu-bionic-kernel.git diff --git a/lib/seq_buf.c b/lib/seq_buf.c index 11f2ae0f9099..6aabb609dd87 100644 --- a/lib/seq_buf.c +++ b/lib/seq_buf.c @@ -144,9 +144,13 @@ int seq_buf_puts(struct seq_buf *s, const char *str) WARN_ON(s->size == 0); + /* Add 1 to len for the trailing null byte which must be there */ + len += 1; + if (seq_buf_can_fit(s, len)) { memcpy(s->buffer + s->len, str, len); - s->len += len; + /* Don't count the trailing null byte against the capacity */ + s->len += len - 1; return 0; } seq_buf_set_overflow(s);