diff options
Diffstat (limited to 'recipes-security/optee-imx/optee-test/0001-xtest-prevent-unexpected-build-warning-with-strncpy.patch')
| -rw-r--r-- | recipes-security/optee-imx/optee-test/0001-xtest-prevent-unexpected-build-warning-with-strncpy.patch | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/recipes-security/optee-imx/optee-test/0001-xtest-prevent-unexpected-build-warning-with-strncpy.patch b/recipes-security/optee-imx/optee-test/0001-xtest-prevent-unexpected-build-warning-with-strncpy.patch deleted file mode 100644 index 0c13dcfcf..000000000 --- a/recipes-security/optee-imx/optee-test/0001-xtest-prevent-unexpected-build-warning-with-strncpy.patch +++ /dev/null | |||
| @@ -1,66 +0,0 @@ | |||
| 1 | Upstream-Status: Backport 3.4.0 | ||
| 2 | |||
| 3 | Signed-off-by: Peter Griffin <peter.griffin@linaro.org> | ||
| 4 | --- | ||
| 5 | From 493574ad1f4f56dd63097a652b87c25c507ce99c Mon Sep 17 00:00:00 2001 | ||
| 6 | From: Etienne Carriere <etienne.carriere@linaro.org> | ||
| 7 | Date: Fri, 21 Dec 2018 15:36:00 +0100 | ||
| 8 | Subject: [PATCH] xtest: prevent unexpected build warning with strncpy | ||
| 9 | MIME-Version: 1.0 | ||
| 10 | Content-Type: text/plain; charset=UTF-8 | ||
| 11 | Content-Transfer-Encoding: 8bit | ||
| 12 | |||
| 13 | This change modifies adbg_run.c to prevent a false positive | ||
| 14 | warning reported by GCC 8.2 on usage of strncpy(): | ||
| 15 | |||
| 16 | build/optee_test/host/xtest/adbg/src/adbg_run.c: In function ‘Do_ADBG_AppendToSuite’: | ||
| 17 | build/optee_test/host/xtest/adbg/src/adbg_run.c:103:3: error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=] | ||
| 18 | strncpy(p, Source_p->SuiteID_p, size); | ||
| 19 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 20 | build/optee_test/host/xtest/adbg/src/adbg_run.c:88:9: note: length computed here | ||
| 21 | size = strlen(Source_p->SuiteID_p); | ||
| 22 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 23 | cc1: all warnings being treated as errors | ||
| 24 | |||
| 25 | From [1]: | ||
| 26 | Using strncpy Safely | ||
| 27 | In general, it is not possible to avoid string truncation by strncpy | ||
| 28 | except by sizing the destination to be at least a byte larger than | ||
| 29 | the length of the source string. With that approach, however, using | ||
| 30 | strncpy becomes unnecessary and the function can be avoided in favor | ||
| 31 | of other APIs such as strcpy or (less preferably) memcpy. Much has | ||
| 32 | been written about the problems with strncpy and we recommend to | ||
| 33 | avoid it whenever possible. It is, however, worth keeping in mind | ||
| 34 | that unlike other standard string-handling functions, strncpy always | ||
| 35 | writes exactly as many characters as specified by the third argument; | ||
| 36 | if the source string is shorter, the function fills the remaining | ||
| 37 | bytes with NULs. | ||
| 38 | |||
| 39 | This change prefers using a snprintf() as used in the alternate | ||
| 40 | instruction block of the strncpy() call. | ||
| 41 | |||
| 42 | [1] https://developers.redhat.com/blog/2018/05/24/detecting-string-truncation-with-gcc-8/ | ||
| 43 | |||
| 44 | Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> | ||
| 45 | Signed-off-by: Simon Hughes <simon.hughes@arm.com> | ||
| 46 | Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> | ||
| 47 | --- | ||
| 48 | host/xtest/adbg/src/adbg_run.c | 2 +- | ||
| 49 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
| 50 | |||
| 51 | diff --git a/host/xtest/adbg/src/adbg_run.c b/host/xtest/adbg/src/adbg_run.c | ||
| 52 | index 406e429..2739db5 100644 | ||
| 53 | --- a/host/xtest/adbg/src/adbg_run.c | ||
| 54 | +++ b/host/xtest/adbg/src/adbg_run.c | ||
| 55 | @@ -100,7 +100,7 @@ int Do_ADBG_AppendToSuite( | ||
| 56 | snprintf(p, size, "%s+%s", Dest_p->SuiteID_p, | ||
| 57 | Source_p->SuiteID_p); | ||
| 58 | else | ||
| 59 | - strncpy(p, Source_p->SuiteID_p, size); | ||
| 60 | + snprintf(p, size, "%s", Source_p->SuiteID_p); | ||
| 61 | free((void *)Dest_p->SuiteID_p); | ||
| 62 | Dest_p->SuiteID_p = p; | ||
| 63 | |||
| 64 | -- | ||
| 65 | 2.7.4 | ||
| 66 | |||
