Skip to contentSkip to conversation

qmi: Fix Secondary DNS overwriting Primary DNS

PATCH Applied Pau Espin Pedrol 2 participants 2 messages Dec 11, 2018

lore
Share & tools
lore
#0 lore raw

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
index dcdf8ae1..f1fd1f12 100644
@@ -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
#1 lore raw

Hi Pau,

Quoted 11 lines · Pau Espin Pedrol

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(-)

Applied, thanks.

Regards,
-Denis