[sr-dev] git:master:9fe84d4a: http_client: use strcpy() instead of strncpy() with sizeof dest buffer

Daniel-Constantin Mierla miconda at gmail.com
Fri Jul 28 10:30:41 CEST 2017


Module: kamailio
Branch: master
Commit: 9fe84d4ad1ec1eae6bcf44b4067b948d9a16e4dc
URL: https://github.com/kamailio/kamailio/commit/9fe84d4ad1ec1eae6bcf44b4067b948d9a16e4dc

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-07-28T10:30:19+02:00

http_client: use strcpy() instead of strncpy() with sizeof dest buffer

- padding the rest of dest buffer with 0 is inneficient

---

Modified: src/modules/http_client/functions.c

---

Diff:  https://github.com/kamailio/kamailio/commit/9fe84d4ad1ec1eae6bcf44b4067b948d9a16e4dc.diff
Patch: https://github.com/kamailio/kamailio/commit/9fe84d4ad1ec1eae6bcf44b4067b948d9a16e4dc.patch

---

diff --git a/src/modules/http_client/functions.c b/src/modules/http_client/functions.c
index c4fc39d6a4..1bdae25df7 100644
--- a/src/modules/http_client/functions.c
+++ b/src/modules/http_client/functions.c
@@ -344,16 +344,14 @@ static int curL_query_url(struct sip_msg* _m, const char* _url, str* _dst,
 			LM_DBG("We received Content-Type: %s\n", ct);
 			if (params->pconn &&
 					strlen(ct)<sizeof(params->pconn->result_content_type)-1) {
-				strncpy(params->pconn->result_content_type, ct,
-						sizeof(params->pconn->result_content_type));
+				strcpy(params->pconn->result_content_type, ct);
 			}
 		}
 		if(url) {
 			LM_DBG("We visited URL: %s\n", url);
 			if (params->pconn
 					&& strlen(url)<sizeof(params->pconn->redirecturl)-1) {
-				strncpy(params->pconn->redirecturl, url ,
-						sizeof(params->pconn->redirecturl));
+				strcpy(params->pconn->redirecturl, url);
 			}
 		}
 	}




More information about the sr-dev mailing list