mirror of git://git.sysmocom.de/ofono
ussd: Rework ussd_request
- Only allocate variables which are needed - Make sure buffers are big enough - converted is a simple string, no need to use fancy printf magic
This commit is contained in:
parent
82e6ddfd4b
commit
f6a4d4a5ce
|
@ -184,11 +184,7 @@ static void at_ussd_request(struct ofono_ussd *ussd, int dcs,
|
||||||
{
|
{
|
||||||
struct ussd_data *data = ofono_ussd_get_data(ussd);
|
struct ussd_data *data = ofono_ussd_get_data(ussd);
|
||||||
struct cb_data *cbd = cb_data_new(cb, user_data);
|
struct cb_data *cbd = cb_data_new(cb, user_data);
|
||||||
char buf[256];
|
char buf[512];
|
||||||
unsigned char unpacked_buf[182];
|
|
||||||
char coded_buf[160];
|
|
||||||
char *converted;
|
|
||||||
long written;
|
|
||||||
enum sms_charset charset;
|
enum sms_charset charset;
|
||||||
|
|
||||||
if (!cbd)
|
if (!cbd)
|
||||||
|
@ -201,6 +197,9 @@ static void at_ussd_request(struct ofono_ussd *ussd, int dcs,
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (charset == SMS_CHARSET_7BIT) {
|
if (charset == SMS_CHARSET_7BIT) {
|
||||||
|
unsigned char unpacked_buf[182];
|
||||||
|
long written;
|
||||||
|
|
||||||
unpack_7bit_own_buf(pdu, len, 0, TRUE, sizeof(unpacked_buf),
|
unpack_7bit_own_buf(pdu, len, 0, TRUE, sizeof(unpacked_buf),
|
||||||
&written, 0, unpacked_buf);
|
&written, 0, unpacked_buf);
|
||||||
|
|
||||||
|
@ -210,12 +209,14 @@ static void at_ussd_request(struct ofono_ussd *ussd, int dcs,
|
||||||
snprintf(buf, sizeof(buf), "AT+CUSD=1,\"%.*s\",%d",
|
snprintf(buf, sizeof(buf), "AT+CUSD=1,\"%.*s\",%d",
|
||||||
(int) written, unpacked_buf, dcs);
|
(int) written, unpacked_buf, dcs);
|
||||||
} else {
|
} else {
|
||||||
converted = encode_hex_own_buf(pdu, len, 0, coded_buf);
|
char coded_buf[321];
|
||||||
|
char *converted = encode_hex_own_buf(pdu, len, 0, coded_buf);
|
||||||
|
|
||||||
if (!converted)
|
if (!converted)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "AT+CUSD=1,\"%.*s\",%d",
|
snprintf(buf, sizeof(buf), "AT+CUSD=1,\"%s\",%d",
|
||||||
strlen(converted), converted, dcs);
|
converted, dcs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->vendor == OFONO_VENDOR_QUALCOMM_MSM) {
|
if (data->vendor == OFONO_VENDOR_QUALCOMM_MSM) {
|
||||||
|
|
Loading…
Reference in New Issue