[LTP] [PATCH 14/15] ujson: writer: Advance buffer on short write

Andrea Cervesato andrea.cervesato@suse.de
Mon Oct 5 15:25:42 CEST 2026


From: Andrea Cervesato <andrea.cervesato@suse.com>

On a short write(), out_writer_file_write() decremented the remaining
length but kept writing from the start of the buffer, so the beginning
of the data was written again and the output file got corrupted.
Advance the buffer pointer by the number of bytes written.

Fixes: c50a0e0751c8 ("libs: Vendor ujson library")
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 libs/ujson/ujson_writer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libs/ujson/ujson_writer.c b/libs/ujson/ujson_writer.c
index 49f73e436..2553d8cd2 100644
--- a/libs/ujson/ujson_writer.c
+++ b/libs/ujson/ujson_writer.c
@@ -411,6 +411,7 @@ static int out_writer_file_write(ujson_writer *self, int fd, const char *buf, ss
 			return 1;
 		}
 
+		buf += ret;
 		buf_len -= ret;
 	} while (buf_len);
 

-- 
2.51.0



More information about the ltp mailing list