Module: kamailio Branch: master Commit: b96de87ae94db2285d7a5f022c38a746d69ae5ef URL: https://github.com/kamailio/kamailio/commit/b96de87ae94db2285d7a5f022c38a746...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2024-04-22T21:43:40+02:00
ipops: define hostname size for ptr structure
- replace the strncpy with strlen with straight strcpy
---
Modified: src/modules/ipops/ipops_pv.c Modified: src/modules/ipops/ipops_pv.h
---
Diff: https://github.com/kamailio/kamailio/commit/b96de87ae94db2285d7a5f022c38a746... Patch: https://github.com/kamailio/kamailio/commit/b96de87ae94db2285d7a5f022c38a746...
---
diff --git a/src/modules/ipops/ipops_pv.c b/src/modules/ipops/ipops_pv.c index 034ec696594..acbe08a4283 100644 --- a/src/modules/ipops/ipops_pv.c +++ b/src/modules/ipops/ipops_pv.c @@ -429,7 +429,7 @@ int ptr_update_pv(str *ip_address, str *name) sr_dns_item_t *dr = NULL; struct sockaddr_in sa; struct sockaddr_in6 sa6; - char hostname[256]; + char hostname[SR_DNS_HOSTNAME_SIZE]; int result; int ip_type; if(ip_address->len > INET6_ADDRSTRLEN) { @@ -499,8 +499,7 @@ int ptr_update_pv(str *ip_address, str *name) }
/* Store the hostname in the sr_dns_item_t structure. */ - strncpy(dr->hostname, hostname, strlen(hostname)); - dr->hostname[strlen(hostname)] = '\0'; + strcpy(dr->hostname, hostname); dr->count = 1;
LM_DBG("reverse dns PV updated for: %s (%d)\n", dr->r[0].addr, dr->count); diff --git a/src/modules/ipops/ipops_pv.h b/src/modules/ipops/ipops_pv.h index 5e9a19be1da..cede3b4217c 100644 --- a/src/modules/ipops/ipops_pv.h +++ b/src/modules/ipops/ipops_pv.h @@ -27,7 +27,7 @@ #define PV_DNS_ADDR 64 #define PV_DNS_RECS 32 #define SR_DNS_PVIDX 1 - +#define SR_DNS_HOSTNAME_SIZE 256 typedef struct _sr_dns_record { int type; @@ -38,7 +38,7 @@ typedef struct _sr_dns_item { str name; unsigned int hashid; - char hostname[256]; + char hostname[SR_DNS_HOSTNAME_SIZE]; int count; int ipv4; int ipv6;