>If the buffer space requirements are changed, the magic constant is
>hard to spot, and the failure is easily overlooked, because it may
>fail only under special conditions.

Good change, I'll push it to devel soon.


Thanks
Atsushi Kumagai

>Signed-off-by: Petr Tesarik <[email protected]>
>---
> makedumpfile.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
>diff --git a/makedumpfile.c b/makedumpfile.c
>index b4b6eca..37dea37 100644
>--- a/makedumpfile.c
>+++ b/makedumpfile.c
>@@ -3949,7 +3949,7 @@ static int
> dump_log_entry(char *logptr, int fp)
> {
>       char *msg, *p, *bufp;
>-      unsigned int i, text_len;
>+      unsigned int i, text_len, buf_need;
>       unsigned long long ts_nsec;
>       char buf[BUFSIZE];
>       ulonglong nanos;
>@@ -3966,9 +3966,11 @@ dump_log_entry(char *logptr, int fp)
>       bufp = buf;
>       bufp += sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
>
>+      /* How much buffer space is needed in the worst case */
>+      buf_need = sizeof("\\xXX\n");
>+
>       for (i = 0, p = msg; i < text_len; i++, p++) {
>-              /* 6bytes = "\\x%02x" + '\n' + '\0' */
>-              if (bufp - buf >= sizeof(buf) - 6) {
>+              if (bufp - buf >= sizeof(buf) - buf_need) {
>                       if (write(info->fd_dumpfile, buf, bufp - buf) < 0)
>                               return FALSE;
>                       bufp = buf;
>--

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Reply via email to