mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-07 23:41:59 +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;
|
||||
|
||||
/* safety check against abnormally long lines */
|
||||
|
||||
if(len + 3 > sizeof(puf)-1) break;
|
||||
|
||||
if(strlen(s) == 4){
|
||||
memset(s2, 0, 3);
|
||||
|
||||
@ -117,7 +121,6 @@ int decodeBase64(char *p){
|
||||
|
||||
s2[2] = k1 | k2;
|
||||
|
||||
// this is binary safe
|
||||
memcpy(puf+len, s2, 3);
|
||||
|
||||
len += 3;
|
||||
@ -300,8 +303,6 @@ void utf8_encode(unsigned char *p){
|
||||
|
||||
if(p == NULL || strlen((char *)p) == 0) return;
|
||||
|
||||
//printf("encoding: *%s*\n", p);
|
||||
|
||||
memset(utf8, 0, MAXBUFSIZE);
|
||||
u = &utf8[0];
|
||||
s = p;
|
||||
@ -310,6 +311,16 @@ void utf8_encode(unsigned char *p){
|
||||
|
||||
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);
|
||||
memcpy(u+count, &__u[0], len);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user