<div dir="ltr">Updated the patch to avoid buffer overrun that may occur when using strcpy.<br>From 4008932553d1c57f12a649653f211086e591dd70 Mon Sep 17 00:00:00 2001<br>From: Kirithika <<a href="mailto:kirithika@multicorewareinc.com">kirithika@multicorewareinc.com</a>><br>Date: Wed, 18 Sep 2024 14:52:12 +0530<br>Subject: [PATCH] Fix issue with left-over filename not being treated as input<br> parameter<br><br>This commit also fixes the buffer overrun issue that may occur due to strcpy<br>---<br> source/x265cli.cpp | 14 ++++++++------<br> 1 file changed, 8 insertions(+), 6 deletions(-)<br><br>diff --git a/source/x265cli.cpp b/source/x265cli.cpp<br>index ca7d9c973..40eac4c8d 100755<br>--- a/source/x265cli.cpp<br>+++ b/source/x265cli.cpp<br>@@ -598,6 +598,7 @@ namespace X265_NS {<br>         for (int view = 0; view < MAX_VIEWS; view++)<br>         {<br>             inputfn[view] = X265_MALLOC(char, sizeof(char) * 1024);<br>+            memset(inputfn[view], 0, sizeof(char) * 1024);<br>         }<br>         const char* reconfn[MAX_LAYERS] = { NULL };<br>         const char *outputfn = NULL;<br>@@ -738,7 +739,7 @@ namespace X265_NS {<br>                 OPT("frames") this->framesToBeEncoded = (uint32_t)x265_atoi(optarg, bError);<br>                 OPT("no-progress") this->bProgress = false;<br>                 OPT("output") outputfn = optarg;<br>-                OPT("input") strcpy(inputfn[0] , optarg);<br>+                OPT("input") strncpy(inputfn[0] , optarg, 1024);<br>                 OPT("recon") reconfn[0] = optarg;<br>                 OPT("input-depth") inputBitDepth = (uint32_t)x265_atoi(optarg, bError);<br>                 OPT("dither") this->bDither = true;<br>@@ -805,10 +806,11 @@ namespace X265_NS {<br>             }<br>         }<br> <br>-#if !ENABLE_MULTIVIEW<br>-        if (optind < argc && !inputfn[0])<br>-            inputfn[0] = argv[optind++];<br>-#endif<br>+        if (param->numViews < 2)<br>+        {<br>+            if (optind < argc && !(*inputfn[0]))<br>+                strncpy(inputfn[0], argv[optind++], 1024);<br>+        }<br>         if (optind < argc && !outputfn)<br>             outputfn = argv[optind++];<br>         if (optind < argc)<br>@@ -1406,7 +1408,7 @@ namespace X265_NS {<br>                         if (0);<br>                         OPT("input")<br>                         {<br>-                            strcpy(fn[numInput++], optarg);<br>+                            strncpy(fn[numInput++], optarg, 1024);<br>                         }<br> <br>                     }<br>-- <br>2.28.0.windows.1<br><br><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><i>Thanks,</i><div><i>Kirithika</i></div></div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 27, 2024 at 2:30 PM Kirithika Kalirathnam <<a href="mailto:kirithika@multicorewareinc.com">kirithika@multicorewareinc.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Please ignore the previous patch and find the updated patch attached.<br>From 89161b8e14b11ad595de610704b70c0a3ccd81c0 Mon Sep 17 00:00:00 2001<br>From: Kirithika <<a href="mailto:kirithika@multicorewareinc.com" target="_blank">kirithika@multicorewareinc.com</a>><br>Date: Wed, 18 Sep 2024 14:52:12 +0530<br>Subject: [PATCH] Fix issue with left-over filename not being treated as input<br> parameter<br><br>---<br> source/x265cli.cpp | 10 ++++++----<br> 1 file changed, 6 insertions(+), 4 deletions(-)<br><br>diff --git a/source/x265cli.cpp b/source/x265cli.cpp<br>index ca7d9c973..ba0b620b7 100755<br>--- a/source/x265cli.cpp<br>+++ b/source/x265cli.cpp<br>@@ -598,6 +598,7 @@ namespace X265_NS {<br>         for (int view = 0; view < MAX_VIEWS; view++)<br>         {<br>             inputfn[view] = X265_MALLOC(char, sizeof(char) * 1024);<br>+            memset(inputfn[view], 0, sizeof(char) * 1024);<br>         }<br>         const char* reconfn[MAX_LAYERS] = { NULL };<br>         const char *outputfn = NULL;<br>@@ -805,10 +806,11 @@ namespace X265_NS {<br>             }<br>         }<br> <br>-#if !ENABLE_MULTIVIEW<br>-        if (optind < argc && !inputfn[0])<br>-            inputfn[0] = argv[optind++];<br>-#endif<br>+        if (param->numViews < 2)<br>+        {<br>+            if (optind < argc && !(*inputfn[0]))<br>+                strcpy(inputfn[0], argv[optind++]);<br>+        }<br>         if (optind < argc && !outputfn)<br>             outputfn = argv[optind++];<br>         if (optind < argc)<br>-- <br>2.28.0.windows.1<br><br><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><i>Thanks,</i><div><i>Kirithika</i></div></div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 27, 2024 at 10:12 AM Kirithika Kalirathnam <<a href="mailto:kirithika@multicorewareinc.com" target="_blank">kirithika@multicorewareinc.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">From 9bdaa0ace80a25523e6e66a4c792c4d81b7249a2 Mon Sep 17 00:00:00 2001<br>From: Kirithika <<a href="mailto:kirithika@multicorewareinc.com" target="_blank">kirithika@multicorewareinc.com</a>><br>Date: Wed, 18 Sep 2024 14:52:12 +0530<br>Subject: [PATCH] Fix issue with left-over filename not being treated as input<br> parameter<br><br>---<br> source/x265cli.cpp | 5 +++--<br> 1 file changed, 3 insertions(+), 2 deletions(-)<br><br>diff --git a/source/x265cli.cpp b/source/x265cli.cpp<br>index ca7d9c973..26f15d5c6 100755<br>--- a/source/x265cli.cpp<br>+++ b/source/x265cli.cpp<br>@@ -598,6 +598,7 @@ namespace X265_NS {<br>         for (int view = 0; view < MAX_VIEWS; view++)<br>         {<br>             inputfn[view] = X265_MALLOC(char, sizeof(char) * 1024);<br>+            memset(inputfn[view], 0, sizeof(char) * 1024);<br>         }<br>         const char* reconfn[MAX_LAYERS] = { NULL };<br>         const char *outputfn = NULL;<br>@@ -806,8 +807,8 @@ namespace X265_NS {<br>         }<br> <br> #if !ENABLE_MULTIVIEW<br>-        if (optind < argc && !inputfn[0])<br>-            inputfn[0] = argv[optind++];<br>+        if (optind < argc && !(*inputfn[0]))<br>+            strcpy(inputfn[0], argv[optind++]);<br> #endif<br>         if (optind < argc && !outputfn)<br>             outputfn = argv[optind++];<br>-- <br>2.28.0.windows.1<br><br><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><i>Thanks,</i><div><i>Kirithika</i></div></div></div></div></div>
</blockquote></div>
</blockquote></div>