- BUG avec urlencode() : s/char/unsigned char/ pour eviter des entiers negatifs !!

- On limite la longueur de encbuf a 160 caracteres
This commit is contained in:
Gregory Colpart 2008-04-20 18:09:50 +00:00
parent 22f44cc80c
commit 6946a3844a

View file

@ -36,7 +36,7 @@ int urlencode (char *msg, char *encmsg) {
char *h = "0123456789abcdef"; char *h = "0123456789abcdef";
unsigned int i; unsigned int i;
char c; unsigned char c;
int ind=0; int ind=0;
for (i=0;i<strlen(msg);i++) { for (i=0;i<strlen(msg);i++) {
@ -183,6 +183,8 @@ int main(void) {
// url encoding // url encoding
memset(&encbuf,0,BUFSIZ); memset(&encbuf,0,BUFSIZ);
bytes_enc = urlencode(buf,encbuf); bytes_enc = urlencode(buf,encbuf);
// limit encbuf to 160 first char
encbuf[159] = '\0';
// debug // debug
//printf("buf (size = %zd) = \n\n%s \n\n",bytes_read,buf); //printf("buf (size = %zd) = \n\n%s \n\n",bytes_read,buf);