diff options
author | Jakob Kaivo <jkk@ung.org> | 2019-10-07 21:30:50 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2019-10-07 21:30:50 -0400 |
commit | 38af7e97537c65d8701d331f7c070dfb31465129 (patch) | |
tree | 5b0dae5c2bd3c7d6fec584e3e478a9a4f266bf75 | |
parent | 2787f07c97ca4a517a5e9d4f03edae9f5554b39b (diff) |
use unsigned char buffers throughout
-rw-r--r-- | uuencode.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -31,10 +31,10 @@ #include <sys/types.h> #include <unistd.h> -static const char *b64s = +static const unsigned char b64s[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static inline int encodechunk(char *in, char *out, int n, int b64) +static inline int encodechunk(const unsigned char *in, unsigned char *out, int n, int b64) { out[0] = (in[0] >> 2) & 0x3f; out[1] = ((in[0] << 4) | ((in[1] >> 4) & 0xf)) & 0x3f; @@ -42,7 +42,7 @@ static inline int encodechunk(char *in, char *out, int n, int b64) out[3] = (in[2]) & 0x3f; for (int i = 0; i < 4; i++) { - out[i] = b64 ? b64s[(int)(out[i])] : out[i] + 0x20; + out[i] = b64 ? b64s[out[i]] : out[i] + 0x20; } if (n < 2) { @@ -64,8 +64,8 @@ static int encode(FILE * in, const char *path, mode_t mode, int b64) int linelength = b64 ? 75 : 43; int nread = 0; - char ibuf[3] = {0}; - char obuf[76] = {0}; + unsigned char ibuf[3] = {0}; + unsigned char obuf[76] = {0}; while ((nread = fread(ibuf, 1, sizeof(ibuf), in)) != 0) { if (nread < 0) { |