X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/75465377b93c9a27450a186342e9cfd2a84b4173..46e14b0f960dcd84fc41df32c74fb3fd89c0ac5c:/client/util.c diff --git a/client/util.c b/client/util.c index 1ebfebea..903791a0 100644 --- a/client/util.c +++ b/client/util.c @@ -103,22 +103,26 @@ void print_hex(const uint8_t * data, const size_t len) } char * sprint_hex(const uint8_t * data, const size_t len) { + + int maxLen = ( len > 1024/3) ? 1024/3 : len; static char buf[1024]; char * tmp = buf; size_t i; - for (i=0; i < len && i < 1024/3; i++, tmp += 3) + for (i=0; i < maxLen; ++i, tmp += 3) sprintf(tmp, "%02x ", data[i]); return buf; } char * sprint_bin(const uint8_t * data, const size_t len) { + + int maxLen = ( len > 1024) ? 1024 : len; static char buf[1024]; char * tmp = buf; size_t i; - for (i=0; i < len && i < 1024; i++, tmp++) + for (i=0; i < maxLen; ++i, ++tmp) sprintf(tmp, "%u", data[i]); return buf;