]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
apparently if had forgotten to commit this:
authorJelte Jansen <jeltejan@NLnetLabs.nl>
Mon, 27 Mar 2006 09:10:23 +0000 (09:10 +0000)
committerJelte Jansen <jeltejan@NLnetLabs.nl>
Mon, 27 Mar 2006 09:10:23 +0000 (09:10 +0000)
b64 zero length string special case

compat/b64_ntop.c
compat/b64_pton.c

index 60de5c98c62f220c6ac76ee2cb095d7499dcdb4f..b2ff41b985f1b24b47c02bfb9b37cc5debdd72ce 100644 (file)
@@ -130,6 +130,15 @@ b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
        uint8_t input[3];
        uint8_t output[4];
        size_t i;
+       
+       if (srclength == 0) {
+               if (targsize > 0) {
+                       target[0] = '\0';
+                       return 0;
+               } else {
+                       return -1;
+               }
+       }
 
        while (2 < srclength) {
                input[0] = *src++;
index e3ac4ef1f71dfa3f70ec1237fe9fc220793d1962..d705ece0123d24aa5fff3b2cde895cee0c02bdf6 100644 (file)
@@ -139,6 +139,10 @@ b64_pton(char const *src, uint8_t *target, size_t targsize)
        state = 0;
        tarindex = 0;
 
+       if (strlen(src) == 0) {
+               return 0;
+       }
+
        while ((ch = *src++) != '\0') {
                if (isspace((unsigned char)ch))        /* Skip whitespace anywhere. */
                        continue;