aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
Diffstat (limited to 'st.c')
-rw-r--r--st.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/st.c b/st.c
index ede7ae6..a8f8232 100644
--- a/st.c
+++ b/st.c
@@ -366,7 +366,7 @@ char
366base64dec_getc(const char **src) 366base64dec_getc(const char **src)
367{ 367{
368 while (**src && !isprint(**src)) (*src)++; 368 while (**src && !isprint(**src)) (*src)++;
369 return *((*src)++); 369 return **src ? *((*src)++) : '='; /* emulate padding if string ends */
370} 370}
371 371
372char * 372char *
@@ -384,6 +384,10 @@ base64dec(const char *src)
384 int c = base64_digits[(unsigned char) base64dec_getc(&src)]; 384 int c = base64_digits[(unsigned char) base64dec_getc(&src)];
385 int d = base64_digits[(unsigned char) base64dec_getc(&src)]; 385 int d = base64_digits[(unsigned char) base64dec_getc(&src)];
386 386
387 /* invalid input. 'a' can be -1, e.g. if src is "\n" (c-str) */
388 if (a == -1 || b == -1)
389 break;
390
387 *dst++ = (a << 2) | ((b & 0x30) >> 4); 391 *dst++ = (a << 2) | ((b & 0x30) >> 4);
388 if (c == -1) 392 if (c == -1)
389 break; 393 break;