From ec8565ff0ac99917cbf846877c1e6602b779c696 Mon Sep 17 00:00:00 2001 From: "David M. Syzdek" Date: Thu, 15 Sep 2022 11:37:16 -0800 Subject: libbindle: updating pctenc_vals[] to use -1 instead of 0 for invalud vals --- lib/libbindle/lencoding.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/libbindle/lencoding.c b/lib/libbindle/lencoding.c index b3a7a4a..4895ac0 100644 --- a/lib/libbindle/lencoding.c +++ b/lib/libbindle/lencoding.c @@ -321,22 +321,22 @@ static const char * hex_chars = "0123456789abcdef"; static const int8_t pctenc_vals[256] = { // 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 0x00 - '+', 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 0x10 - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ',', '-', '.', '/', // 0x20 - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', 0x0, 0x0, 0x0, 0x0, // 0x30 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x00 + '+', -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x10 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ',', '-', '.', '/', // 0x20 + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', -1, -1, -1, -1, // 0x30 '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', // 0x40 - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 0x0, 0x0, 0x0, 0x0, '_', // 0x50 - 0x0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', // 0x60 - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0x0, 0x0, 0x0, '~', 0x0, // 0x70 - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 0x80 - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 0x90 - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 0xA0 - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 0xB0 - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 0xC0 - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 0xD0 - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 0xE0 - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, '~', 0x0, // 0xF0 + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', -1, -1, -1, -1, '_', // 0x50 + -1, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', // 0x60 + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', -1, -1, -1, '~', -1, // 0x70 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x80 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x90 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0xA0 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0xB0 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0xC0 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0xD0 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0xE0 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, '~', -1, // 0xF0 }; @@ -995,7 +995,7 @@ bindle_pctenc_decode( // decodes percent-encode encoded data for(dpos = 0, spos = 0; (spos < n); dpos++, spos++) { - if (pctenc_vals[(uint8_t)src[spos]] != 0) + if (pctenc_vals[(uint8_t)src[spos]] != -1) dst[dpos] = (uint8_t)src[spos]; else if (src[spos] == '+') dst[dpos] = ' ' ; @@ -1037,7 +1037,7 @@ bindle_pctenc_encode( for(spos = 0, dpos = 0; (spos < n); spos++, dpos++) { - if ((dst[dpos] = pctenc_vals[src[spos]]) != 0) + if ((dst[dpos] = pctenc_vals[src[spos]]) != -1) continue; if (src[spos] == ' ') { @@ -1091,7 +1091,7 @@ bindle_pctenc_verify( } if (src[pos] == '+') continue; - if (pctenc_vals[(unsigned char)src[pos]] == 0x00) + if (pctenc_vals[(unsigned char)src[pos]] == -1) return(-1); }; return(size); -- cgit v1.2.3