From 13440f1ec352768a7c0b598adf5e74b5d881d5e6 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sun, 25 Apr 2021 04:40:38 +0800 Subject: [PATCH] Fix the the wrong boundary calculation in chunk.c Signed-off-by: Xiang Xiao Change-Id: Ib4752235c564fb9f876a50a64383e5499ac3291b --- chunk.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chunk.c b/chunk.c index 9f3d52f8..334bb7bf 100644 --- a/chunk.c +++ b/chunk.c @@ -484,7 +484,7 @@ static void *alloc_slots(const int level_n) /* add in all of the unused slots to the linked list */ new_c = 1; for (new_p = &block_p->eb_first_slot; - (char *)new_p + size < (char *)magic3_p; + (char *)new_p + size <= (char *)magic3_p; new_p = (skip_alloc_t *)((char *)new_p + size)) { new_p->sa_level_n = level_n; new_p->sa_next_p[0] = entry_free_list[level_n]; @@ -746,7 +746,7 @@ static int expand_chars(const void *buf, const int buf_size, /* did we find one? */ if (*(spec_p - 1) != '\0') { - if (out_p + 2 >= bounds_p) { + if (out_p + 2 > bounds_p) { break; } out_p = append_format(out_p, bounds_p, "\\%c", *(spec_p - 1)); @@ -755,14 +755,14 @@ static int expand_chars(const void *buf, const int buf_size, /* print out any 7-bit printable characters */ if (*buf_p < 128 && isprint(*buf_p)) { - if (out_p + 1 >= bounds_p) { + if (out_p + 1 > bounds_p) { break; } *out_p = *(char *)buf_p; out_p += 1; } else { - if (out_p + 4 >= bounds_p) { + if (out_p + 4 > bounds_p) { break; } out_p = append_format(out_p, bounds_p, "\\%03o", *buf_p);