Skip to contentSkip to conversation

ussd: Fix crash with long ussd string

PATCH In review Nicolas Bertrand 2 participants 2 messages Mar 30, 2012

lore
Share & tools
lore
#1 lore raw
In reply to Nicolas Bertrand

Hi Nicolas,

Quoted 12 lines · Nicolas Bertrand

Some ZTE modem convert USSD string into UCS2 without respecting the limitation of 160 bytes. So cut off the string if greater than this limit

---
 drivers/atmodem/ussd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/atmodem/ussd.c +0 -0
index 443251a..bdee2d9 100644

drivers/atmodem/ussd.c static void cusd_parse(GAtResult *result, struct ofono_ussd *ussd) · line 164

Quoted 8 lines
drivers/atmodem/ussd.c +1 -1
@@ -158,7 +158,7 @@ static void cusd_parse(GAtResult *result, struct ofono_ussd *ussd)
 
 	case SMS_CHARSET_8BIT:
 	case SMS_CHARSET_UCS2:
-		msg_ptr = decode_hex_own_buf(content, -1, &msg_len, 0, msg);
+		msg_ptr = decode_hex_own_buf(content, 320, &msg_len, 0, msg);
 		break;
 	}
 

This isn't really the problem. From the logs it seems that the ZTE modem is sending us plain-text data that is hex-encoded in UCS2.

e.g.:

ofonod[1051]: Modem: < \r\n+CUSD:
1,"006D006F0062006900630061007200740065000A0056006F007400720065002000630072006500640069007400200065007300740020006500700075006900730065002E000A0050006F0075007200200063006F006E00730065007200760065007200200076006F0074007200650020006E0075006D00650072006F00200030003600340035003300310032003100310038000A00700065006E00730065007A0020006100200072006500630068006100720067006500720020006100760061006E00740020006C0065002000320031002F00300037002F00310032000A0031003D005200650063006800610072006700650072000A0032003D004D0065006E0075000A0033003D00410069006400650020002000200020",72\r\n

-> 006D, 006F, 0062, 0069, 0063, 0061, 0072, 0074, 0065 ...
m o b i c a r t e ...

Regards,
-Denis

#0 lore raw

PATCH 1/1 ussd: Fix crash with long ussd string

Some ZTE modem convert USSD string into UCS2 without respecting the limitation of 160 bytes. So cut off the string if greater than this limit

---
 drivers/atmodem/ussd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/atmodem/ussd.c +1 -1
index 443251a..bdee2d9 100644
@@ -158,7 +158,7 @@ static void cusd_parse(GAtResult *result, struct ofono_ussd *ussd)
 
 	case SMS_CHARSET_8BIT:
 	case SMS_CHARSET_UCS2:
-		msg_ptr = decode_hex_own_buf(content, -1, &msg_len, 0, msg);
+		msg_ptr = decode_hex_own_buf(content, 320, &msg_len, 0, msg);
 		break;
 	}
 
Signature · 1 line
1.7.5.4