From 7bc6fac3ce7720791d072c02479e0d8170902c59 Mon Sep 17 00:00:00 2001 From: marshmellow42 Date: Wed, 9 Dec 2015 20:40:12 -0500 Subject: [PATCH] fix sprint_bin bug i made :( --- client/util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/util.c b/client/util.c index 35af3d66..e8b72e81 100644 --- a/client/util.c +++ b/client/util.c @@ -126,7 +126,12 @@ char *sprint_hex(const uint8_t *data, const size_t len) { char *sprint_bin_break(const uint8_t *data, const size_t len, const uint8_t breaks) { // make sure we don't go beyond our char array memory - int max_len = ( len+(len/breaks) > MAX_BIN_BREAK_LENGTH ) ? MAX_BIN_BREAK_LENGTH : len+(len/breaks); + int max_len; + if (breaks==0) + max_len = ( len > MAX_BIN_BREAK_LENGTH ) ? MAX_BIN_BREAK_LENGTH : len; + else + max_len = ( len+(len/breaks) > MAX_BIN_BREAK_LENGTH ) ? MAX_BIN_BREAK_LENGTH : len+(len/breaks); + static char buf[MAX_BIN_BREAK_LENGTH]; // 3072 + end of line characters if broken at 8 bits //clear memory memset(buf, 0x00, sizeof(buf)); -- 2.39.5