Fixed skipping the UDH when parsing PDUs in 7-bit encoding
This commit is contained in:
parent
0e214179ea
commit
60d16be4b2
@ -3248,17 +3248,15 @@ static char * _cmgr_pdu_parse_encoding_default(char const * pdu, size_t len,
|
|||||||
char * r;
|
char * r;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
fprintf(stderr, "DEBUG: %s(%lu, %lu)\n", __func__, i, hdr);
|
||||||
#endif
|
#endif
|
||||||
if((p = malloc(len - i + 1)) == NULL)
|
if((p = malloc(len - i + 1)) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
if(hdr != 0)
|
if(hdr != 0)
|
||||||
{
|
{
|
||||||
/* FIXME actually parse the header */
|
/* FIXME actually parse the header */
|
||||||
u = 2 + (hdr * 2);
|
i += 2 + (hdr * 2);
|
||||||
if(u % 7 != 0) /* fill bits */
|
shift = (hdr + 1) % 7;
|
||||||
u += 7 - (u % 7);
|
|
||||||
i += u;
|
|
||||||
}
|
}
|
||||||
p[0] = '\0';
|
p[0] = '\0';
|
||||||
for(j = 0, rest = 0; i + 1 < len; i+=2)
|
for(j = 0, rest = 0; i + 1 < len; i+=2)
|
||||||
@ -3267,9 +3265,11 @@ static char * _cmgr_pdu_parse_encoding_default(char const * pdu, size_t len,
|
|||||||
if(sscanf(q, "%02X", &u) != 1)
|
if(sscanf(q, "%02X", &u) != 1)
|
||||||
break; /* FIXME report an error instead? */
|
break; /* FIXME report an error instead? */
|
||||||
byte = u;
|
byte = u;
|
||||||
p[j] = (byte << (shift + 1) >> (shift + 1) << shift) & 0x7f;
|
p[j] = (((byte << (shift + 1)) >> (shift + 1)) << shift) & 0x7f;
|
||||||
p[j] |= rest;
|
p[j] |= rest;
|
||||||
p[j] = _hayes_convert_char_to_iso(p[j]);
|
p[j] = _hayes_convert_char_to_iso(p[j]);
|
||||||
|
/* ignore the first character if there is a header */
|
||||||
|
if(hdr == 0 || j != 0)
|
||||||
j++;
|
j++;
|
||||||
rest = (byte >> (7 - shift)) & 0x7f;
|
rest = (byte >> (7 - shift)) & 0x7f;
|
||||||
if(++shift == 7)
|
if(++shift == 7)
|
||||||
|
Loading…
Reference in New Issue
Block a user