]> arthur.barton.de Git - netatalk.git/commitdiff
make push/pull ascii functions return EILSEQ for extended characters
authorbfernhomberg <bfernhomberg>
Fri, 12 Sep 2003 19:48:07 +0000 (19:48 +0000)
committerbfernhomberg <bfernhomberg>
Fri, 12 Sep 2003 19:48:07 +0000 (19:48 +0000)
libatalk/unicode/iconv.c

index 1f545bbd0820b8d8f6faa786af92919ebc74fe0b..54fa9d125eeacd3d686a79bc8fd0e1f0656a6567 100644 (file)
@@ -366,8 +366,14 @@ static size_t ascii_pull(void *cd, char **inbuf, size_t *inbytesleft,
                         char **outbuf, size_t *outbytesleft)
 {
        while (*inbytesleft >= 1 && *outbytesleft >= 2) {
-               (*outbuf)[0] = (*inbuf)[0];
-               (*outbuf)[1] = 0;
+               if ((unsigned char)(*inbuf)[0] < 0x80) {
+                       (*outbuf)[0] = (*inbuf)[0];
+                       (*outbuf)[1] = 0;
+               }
+               else {
+                       errno = EILSEQ;
+                       return -1;
+               }
                (*inbytesleft)  -= 1;
                (*outbytesleft) -= 2;
                (*inbuf)  += 1;
@@ -388,8 +394,12 @@ static size_t ascii_push(void *cd, char **inbuf, size_t *inbytesleft,
        int ir_count=0;
 
        while (*inbytesleft >= 2 && *outbytesleft >= 1) {
-               (*outbuf)[0] = (*inbuf)[0] & 0x7F;
-               if ((*inbuf)[1]) ir_count++;
+               if ((unsigned char)(*inbuf)[0] < 0x80 && (*inbuf)[1] == 0) 
+                       (*outbuf)[0] = (*inbuf)[0];
+               else {
+                       errno = EILSEQ;
+                       return -1;
+               }       
                (*inbytesleft)  -= 2;
                (*outbytesleft) -= 1;
                (*inbuf)  += 2;