Просмотр исходного кода

ims_qos: strip square brackets from ipv6 address for inet_pton()

- reported by GH #364
Daniel-Constantin Mierla 9 лет назад
Родитель
Сommit
505fb2c3c0
1 измененных файлов с 7 добавлено и 2 удалено
  1. 7 2
      modules/ims_qos/rx_avp.c

+ 7 - 2
modules/ims_qos/rx_avp.c

@@ -185,8 +185,13 @@ int rx_add_framed_ip_avp(AAA_AVP_LIST * list, str ip, uint16_t version) {
         }
         ip_buflen = len;
     }
-    memcpy(ip_buf, ip.s, ip.len);
-    ip_buf[ip.len] = '\0';
+	if(ip.s[0]=='[' && ip.s[ip.len-1]==']') {
+		memcpy(ip_buf, ip.s+1, ip.len-2);
+		ip_buf[ip.len-2] = '\0';
+	} else {
+		memcpy(ip_buf, ip.s, ip.len);
+		ip_buf[ip.len] = '\0';
+	}
     
     ip_adr.addr.ai_family = version;