diff options
author | José Bollo <jose.bollo@iot.bzh> | 2015-12-13 22:21:49 +0100 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2015-12-13 22:21:49 +0100 |
commit | e2de563d1ecb4585ce68521bd42f3ef45ac79f16 (patch) | |
tree | 94d57add5536e30b7296d6ab36d92d363441170b /src/wgtpkg-base64.c | |
parent | 12a227a2fc574cf0fd560453e1cdd15c50550abb (diff) |
work in progress
Change-Id: I197678515772982ab6dd2fd949fa2a54ca4f268f
Diffstat (limited to 'src/wgtpkg-base64.c')
-rw-r--r-- | src/wgtpkg-base64.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/wgtpkg-base64.c b/src/wgtpkg-base64.c index 5cf6f8a..4e6d84e 100644 --- a/src/wgtpkg-base64.c +++ b/src/wgtpkg-base64.c @@ -19,6 +19,7 @@ #include <string.h> #include <syslog.h> +#include "verbose.h" #include "wgtpkg.h" static char tob64(char x) @@ -38,12 +39,12 @@ char *base64encw(const char *buffer, int length, int width) char *result; if (width == 0 || width % 4) { - syslog(LOG_ERR, "bad width in base64enc"); + ERROR("bad width in base64enc"); return NULL; } result = malloc(2 + 4 * ((length + 2) / 3) + (length / width)); if (result == NULL) { - syslog(LOG_ERR, "malloc failed in base64enc"); + ERROR("malloc failed in base64enc"); return NULL; } in = out = 0; @@ -108,7 +109,7 @@ int base64dec(const char *buffer, char **output) len = strlen(buffer); result = malloc(3 * ((3 + len) / 4)); if (result == NULL) { - syslog(LOG_ERR, "malloc failed in base64dec"); + ERROR("malloc failed in base64dec"); return -1; } in = out = 0; @@ -116,7 +117,7 @@ int base64dec(const char *buffer, char **output) in++; while (buffer[in]) { if (in + 4 > len) { - syslog(LOG_ERR, "unexpected input size in base64dec"); + ERROR("unexpected input size in base64dec"); free(result); return -1; } @@ -126,12 +127,12 @@ int base64dec(const char *buffer, char **output) x3 = (unsigned char)fromb64(buffer[in+3]); in += 4; if (x0 == 'E' || x1 == 'E' || x2 == 'E' || x3 == 'E') { - syslog(LOG_ERR, "unexpected input character in base64dec"); + ERROR("unexpected input character in base64dec"); free(result); return -1; } if (x0 == '@' || x1 == '@' || (x2 == '@' && x3 != '@')) { - syslog(LOG_ERR, "unexpected termination character in base64dec"); + ERROR("unexpected termination character in base64dec"); free(result); return -1; } @@ -145,7 +146,7 @@ int base64dec(const char *buffer, char **output) else if (!buffer[in]) out += 1 + (x2 != '@'); else { - syslog(LOG_ERR, "unexpected continuation in base64dec"); + ERROR("unexpected continuation in base64dec"); free(result); return -1; } |