aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid M. Syzdek <david@syzdek.net>2022-09-15 11:37:16 -0800
committerDavid M. Syzdek <david@syzdek.net>2022-09-15 11:37:16 -0800
commitec8565ff0ac99917cbf846877c1e6602b779c696 (patch)
tree1bcb6df4142e8e8299fd03a92e309db848d36c9b
parentaa588253f3d26f711a6bc76082cf324c9f349751 (diff)
downloadbindletools-ec8565ff0ac99917cbf846877c1e6602b779c696.tar.gz
bindletools-ec8565ff0ac99917cbf846877c1e6602b779c696.tar.bz2
bindletools-ec8565ff0ac99917cbf846877c1e6602b779c696.tar.xz
bindletools-ec8565ff0ac99917cbf846877c1e6602b779c696.zip
libbindle: updating pctenc_vals[] to use -1 instead of 0 for invalud vals
-rw-r--r--lib/libbindle/lencoding.c36
1 files 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";
321static const int8_t pctenc_vals[256] = 321static const int8_t pctenc_vals[256] =
322{ 322{
323// 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 323// 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
324 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 0x00 324 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x00
325 '+', 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 0x10 325 '+', -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x10
326 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ',', '-', '.', '/', // 0x20 326 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ',', '-', '.', '/', // 0x20
327 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', 0x0, 0x0, 0x0, 0x0, // 0x30 327 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', -1, -1, -1, -1, // 0x30
328 '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', // 0x40 328 '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', // 0x40
329 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 0x0, 0x0, 0x0, 0x0, '_', // 0x50 329 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', -1, -1, -1, -1, '_', // 0x50
330 0x0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', // 0x60 330 -1, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', // 0x60
331 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0x0, 0x0, 0x0, '~', 0x0, // 0x70 331 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', -1, -1, -1, '~', -1, // 0x70
332 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 0x80 332 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x80
333 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 0x90 333 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x90
334 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 0xA0 334 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0xA0
335 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 0xB0 335 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0xB0
336 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 0xC0 336 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0xC0
337 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 0xD0 337 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0xD0
338 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 0xE0 338 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0xE0
339 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, '~', 0x0, // 0xF0 339 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, '~', -1, // 0xF0
340}; 340};
341 341
342 342
@@ -995,7 +995,7 @@ bindle_pctenc_decode(
995 // decodes percent-encode encoded data 995 // decodes percent-encode encoded data
996 for(dpos = 0, spos = 0; (spos < n); dpos++, spos++) 996 for(dpos = 0, spos = 0; (spos < n); dpos++, spos++)
997 { 997 {
998 if (pctenc_vals[(uint8_t)src[spos]] != 0) 998 if (pctenc_vals[(uint8_t)src[spos]] != -1)
999 dst[dpos] = (uint8_t)src[spos]; 999 dst[dpos] = (uint8_t)src[spos];
1000 else if (src[spos] == '+') 1000 else if (src[spos] == '+')
1001 dst[dpos] = ' ' ; 1001 dst[dpos] = ' ' ;
@@ -1037,7 +1037,7 @@ bindle_pctenc_encode(
1037 1037
1038 for(spos = 0, dpos = 0; (spos < n); spos++, dpos++) 1038 for(spos = 0, dpos = 0; (spos < n); spos++, dpos++)
1039 { 1039 {
1040 if ((dst[dpos] = pctenc_vals[src[spos]]) != 0) 1040 if ((dst[dpos] = pctenc_vals[src[spos]]) != -1)
1041 continue; 1041 continue;
1042 if (src[spos] == ' ') 1042 if (src[spos] == ' ')
1043 { 1043 {
@@ -1091,7 +1091,7 @@ bindle_pctenc_verify(
1091 } 1091 }
1092 if (src[pos] == '+') 1092 if (src[pos] == '+')
1093 continue; 1093 continue;
1094 if (pctenc_vals[(unsigned char)src[pos]] == 0x00) 1094 if (pctenc_vals[(unsigned char)src[pos]] == -1)
1095 return(-1); 1095 return(-1);
1096 }; 1096 };
1097 return(size); 1097 return(size);