Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 1 | From 1ba007583b83468494c4146bcb7267d863de6a7b Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Fri, 26 Feb 2021 23:54:10 -0800 |
| 4 | Subject: [PATCH] fix strncpy bound error |
| 5 | |
| 6 | This patch fixes the following error while using gcc 11 |
| 7 | error: 'char* __builtin_strncpy(char*, const char*, long unsigned int)' specified bound depends on the length of the source argument [-Werror=stringop-overflow=] |
| 8 | |
| 9 | Upstream-Status: Submitted [https://github.com/KhronosGroup/SPIRV-Tools/pull/4151] |
| 10 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 11 | --- |
| 12 | source/diagnostic.cpp | 2 +- |
| 13 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 14 | |
| 15 | diff --git a/source/diagnostic.cpp b/source/diagnostic.cpp |
| 16 | index edc27c8fd..77c29d70c 100644 |
| 17 | --- a/source/diagnostic.cpp |
| 18 | +++ b/source/diagnostic.cpp |
| 19 | @@ -37,7 +37,7 @@ spv_diagnostic spvDiagnosticCreate(const spv_position position, |
| 20 | diagnostic->position = *position; |
| 21 | diagnostic->isTextSource = false; |
| 22 | memset(diagnostic->error, 0, length); |
| 23 | - strncpy(diagnostic->error, message, length); |
| 24 | + memcpy(diagnostic->error, message, length); |
| 25 | return diagnostic; |
| 26 | } |
| 27 | |
| 28 | -- |
| 29 | 2.30.1 |
| 30 | |