From ba5054cc77bef76dae44b3debc80a499d36b782d Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Fri, 19 Nov 2010 15:27:12 -0500 Subject: [PATCH] terminal: don't rely on strlen(bytes) for write size We're printing stuff to the terminal. This may include NUL bytes once in a while. We shouldn't rely on strlen() to determine how many bytes to write. --- src/libply-splash-core/ply-terminal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libply-splash-core/ply-terminal.c b/src/libply-splash-core/ply-terminal.c index 22db27df..a4b2a5aa 100644 --- a/src/libply-splash-core/ply-terminal.c +++ b/src/libply-splash-core/ply-terminal.c @@ -271,16 +271,17 @@ ply_terminal_write (ply_terminal_t *terminal, { va_list args; char *string; + int size; assert (terminal != NULL); assert (format != NULL); string = NULL; va_start (args, format); - vasprintf (&string, format, args); + size = vasprintf (&string, format, args); va_end (args); - write (terminal->fd, string, strlen (string)); + write (terminal->fd, string, size); free (string); }