From 2b70333d7ecd533c7f5eb062f4f46126d2c1dbb3 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 25 Nov 2018 11:19:36 +0000 Subject: [PATCH] fix string truncation regression buf_append was dropping the final byte --- libvips/iofuncs/buf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libvips/iofuncs/buf.c b/libvips/iofuncs/buf.c index 08b9b5d4..c21b312a 100644 --- a/libvips/iofuncs/buf.c +++ b/libvips/iofuncs/buf.c @@ -275,11 +275,12 @@ vips_buf_appendns( VipsBuf *buf, const char *str, int sz ) */ avail = buf->mx - buf->i - 4; - /* Amount we actually copy. - */ cpy = VIPS_MIN( n, avail ); - vips_strncpy( buf->base + buf->i, str, cpy ); + /* Can't use vips_strncpy() here, we don't want to drop the end of the + * string. + */ + strncpy( buf->base + buf->i, str, cpy ); buf->i += cpy; if( buf->i >= buf->mx - 4 ) {