[vlc-commits] satip: use memcpy()

Rémi Denis-Courmont git at videolan.org
Sat Dec 1 22:47:11 CET 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Dec  1 23:39:48 2018 +0200| [c4dc96ef735d1cd53cd6996063783d955ed94fcb] | committer: Rémi Denis-Courmont

satip: use memcpy()

If 'len <= strlen(src)', then 'strncpy(dst, src, len)' is equivalent
to 'memcpy(dst, src, len)'.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c4dc96ef735d1cd53cd6996063783d955ed94fcb
---

 modules/access/satip.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/modules/access/satip.c b/modules/access/satip.c
index ae71e5fb86..c4e2446afa 100644
--- a/modules/access/satip.c
+++ b/modules/access/satip.c
@@ -142,7 +142,7 @@ static void parse_session(char *request_line, char *session, unsigned max, int *
     tok = strtok_r(request_line, ";", &state);
     if (tok == NULL)
         return;
-    strncpy(session, tok, __MIN(strlen(tok), max - 1));
+    memcpy(session, tok, __MIN(strlen(tok), max - 1));
 
     while ((tok = strtok_r(NULL, ";", &state)) != NULL) {
         if (strncmp(tok, "timeout=", 8) == 0) {
@@ -182,13 +182,13 @@ static int parse_transport(stream_t *access, char *request_line) {
 
     while ((tok = strtok_r(NULL, ";", &state)) != NULL) {
         if (strncmp(tok, "destination=", 12) == 0) {
-            strncpy(sys->udp_address, tok + 12, __MIN(strlen(tok + 12), UDP_ADDRESS_LEN - 1));
+            memcpy(sys->udp_address, tok + 12, __MIN(strlen(tok + 12), UDP_ADDRESS_LEN - 1));
         } else if (strncmp(tok, "port=", 5) == 0) {
             char port[6];
             char *end;
 
             memset(port, 0x00, 6);
-            strncpy(port, tok + 5, __MIN(strlen(tok + 5), 5));
+            memcpy(port, tok + 5, __MIN(strlen(tok + 5), 5));
             if ((end = strstr(port, "-")) != NULL)
                 *end = '\0';
             err = parse_port(port, &sys->udp_port);



More information about the vlc-commits mailing list