aboutsummaryrefslogtreecommitdiffstats
path: root/lib/seq_buf.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/seq_buf.c')
-rw-r--r--lib/seq_buf.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/seq_buf.c b/lib/seq_buf.c
index 11f2ae0f9099..bd807f545a9d 100644
--- a/lib/seq_buf.c
+++ b/lib/seq_buf.c
@@ -140,13 +140,17 @@ int seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary)
140 */ 140 */
141int seq_buf_puts(struct seq_buf *s, const char *str) 141int seq_buf_puts(struct seq_buf *s, const char *str)
142{ 142{
143 unsigned int len = strlen(str); 143 size_t len = strlen(str);
144 144
145 WARN_ON(s->size == 0); 145 WARN_ON(s->size == 0);
146 146
147 /* Add 1 to len for the trailing null byte which must be there */
148 len += 1;
149
147 if (seq_buf_can_fit(s, len)) { 150 if (seq_buf_can_fit(s, len)) {
148 memcpy(s->buffer + s->len, str, len); 151 memcpy(s->buffer + s->len, str, len);
149 s->len += len; 152 /* Don't count the trailing null byte against the capacity */
153 s->len += len - 1;
150 return 0; 154 return 0;
151 } 155 }
152 seq_buf_set_overflow(s); 156 seq_buf_set_overflow(s);