qmi: Fix Secondary DNS overwriting Primary DNS
PATCH 1/1 qmi: Fix Secondary DNS overwriting Primary DNS
inet_ntoa was called twice in a row and as a result both primay and secondary DNS were pointing to same static buffer containing last value (secondary DNS).
As a result, ofono always advertised the secondary DNS twice through DBus ConnectionContext.GetProperties 'DomainNameServers'.
Related: https://osmocom.org/issues/3031
--- drivers/qmimodem/gprs-context.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/qmimodem/gprs-context.c +3 -2
@@ -88,6 +88,7 @@ static void get_settings_cb(struct qmi_result *result, void *user_data)char * straddr;char * apn;const char *dns[3 ] = {NULL ,NULL ,NULL }; +char dns_buf[2 ][INET_ADDRSTRLEN ];DBG ("" );
@@ -131,14 +132,14 @@ static void get_settings_cb(struct qmi_result *result, void *user_data)if (qmi_result_get_uint32 (result,QMI_WDS_RESULT_PRIMARY_DNS , &ip_addr)) { addr.s_addr =htonl (ip_addr); - dns[0 ] =inet_ntoa (addr); + dns[0 ] =inet_ntop (AF_INET , &addr, dns_buf[0 ],sizeof (dns_buf[0 ]));DBG ("Primary DNS: %s" , dns[0 ]); }if (qmi_result_get_uint32 (result,QMI_WDS_RESULT_SECONDARY_DNS , &ip_addr)) { addr.s_addr =htonl (ip_addr); - dns[1 ] =inet_ntoa (addr); + dns[1 ] =inet_ntop (AF_INET , &addr, dns_buf[1 ],sizeof (dns_buf[1 ]));DBG ("Secondary DNS: %s" , dns[1 ]); }
Signature · 1 line
2.19.2
Denis Kenzior
AppliedHi Pau,
Quoted 11 lines · Pau Espin Pedrol
inet_ntoawas called twice in a row and as a result both primay and secondary DNS were pointing to same static buffer containing last value (secondary DNS).As a result, ofono always advertised the secondary DNS twice through DBus ConnectionContext.GetProperties 'DomainNameServers'.
Related: https://osmocom.org/issues/3031
--- drivers/qmimodem/gprs-context.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Applied, thanks.
Regards,
-Denis