mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 17:40:11 +01:00
fixed a bug in utf8_encoding abnormally long lines
This commit is contained in:
parent
4a97a90934
commit
a3d0b399c1
@ -93,6 +93,10 @@ int decodeBase64(char *p){
|
|||||||
|
|
||||||
i += 3;
|
i += 3;
|
||||||
|
|
||||||
|
/* safety check against abnormally long lines */
|
||||||
|
|
||||||
|
if(len + 3 > sizeof(puf)-1) break;
|
||||||
|
|
||||||
if(strlen(s) == 4){
|
if(strlen(s) == 4){
|
||||||
memset(s2, 0, 3);
|
memset(s2, 0, 3);
|
||||||
|
|
||||||
@ -117,7 +121,6 @@ int decodeBase64(char *p){
|
|||||||
|
|
||||||
s2[2] = k1 | k2;
|
s2[2] = k1 | k2;
|
||||||
|
|
||||||
// this is binary safe
|
|
||||||
memcpy(puf+len, s2, 3);
|
memcpy(puf+len, s2, 3);
|
||||||
|
|
||||||
len += 3;
|
len += 3;
|
||||||
@ -300,8 +303,6 @@ void utf8_encode(unsigned char *p){
|
|||||||
|
|
||||||
if(p == NULL || strlen((char *)p) == 0) return;
|
if(p == NULL || strlen((char *)p) == 0) return;
|
||||||
|
|
||||||
//printf("encoding: *%s*\n", p);
|
|
||||||
|
|
||||||
memset(utf8, 0, MAXBUFSIZE);
|
memset(utf8, 0, MAXBUFSIZE);
|
||||||
u = &utf8[0];
|
u = &utf8[0];
|
||||||
s = p;
|
s = p;
|
||||||
@ -310,6 +311,16 @@ void utf8_encode(unsigned char *p){
|
|||||||
|
|
||||||
utf8_encode_char(*s, &__u[0], sizeof(__u), &len);
|
utf8_encode_char(*s, &__u[0], sizeof(__u), &len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* this condition should never happen, as according to the RFCs:
|
||||||
|
*
|
||||||
|
* "Each line of characters MUST be no more than 998 characters, and
|
||||||
|
* SHOULD be no more than 78 characters, excluding the CRLF."
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
if(count+len > sizeof(utf8)-1) break;
|
||||||
|
|
||||||
//printf("%s", __u);
|
//printf("%s", __u);
|
||||||
memcpy(u+count, &__u[0], len);
|
memcpy(u+count, &__u[0], len);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user