From bbed1e56cd910e0a4f55290b4fa3dbf9b6157ca7 Mon Sep 17 00:00:00 2001 From: Milad Farazmand Date: Tue, 21 Apr 2020 17:16:53 +0000 Subject: [PATCH] deps: V8: cherry-pick e1eac1b16c96 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit message: Fix compilation error with devtoolset-8 We are compiling V8 using devtoolset-8 and it is generating a new compilation error related to String Truncation: error: ‘char* strncpy(char*, const char*, size_t)’ output truncated copying between 1 and 15 bytes from a string of length 15 [-Werror=stringop-truncation] strncpy(buffer, unicode_utf8, i); Which basically means the null terminating character was not added to the end of the buffer: https://developers.redhat.com/blog/2018/05/24/detecting-string-truncation-with-gcc-8/ This CL will changes 2 uses of "strncpy" to "memcpy" as strings are being copied partially and `\n` being added at a later stage. Change-Id: I3656afb00463d70ddb8700a487a1978b793e1d09 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2155038 Reviewed-by: Andreas Haas Reviewed-by: Toon Verwaest Commit-Queue: Milad Farazmand Cr-Commit-Position: refs/heads/master@{#67277} Refs: https://github.com/v8/v8/commit/e1eac1b16c966879102c2310d7649637227eaa02 PR-URL: https://github.com/nodejs/node/pull/32974 Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: Ujjwal Sharma --- common.gypi | 2 +- deps/v8/test/cctest/parsing/test-scanner-streams.cc | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common.gypi b/common.gypi index 040d0d1593eb15..476cd2dbdd1606 100644 --- a/common.gypi +++ b/common.gypi @@ -35,7 +35,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.30', + 'v8_embedder_string': '-node.31', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/test/cctest/parsing/test-scanner-streams.cc b/deps/v8/test/cctest/parsing/test-scanner-streams.cc index 35b7048bb01e3b..28687cef5b4b25 100644 --- a/deps/v8/test/cctest/parsing/test-scanner-streams.cc +++ b/deps/v8/test/cctest/parsing/test-scanner-streams.cc @@ -331,8 +331,8 @@ TEST(Utf8AdvanceUntilOverChunkBoundaries) { for (size_t i = 1; i < len; i++) { // Copy source string into buffer, splitting it at i. // Then add three chunks, 0..i-1, i..strlen-1, empty. - strncpy(buffer, unicode_utf8, i); - strncpy(buffer + i + 1, unicode_utf8 + i, len - i); + memcpy(buffer, unicode_utf8, i); + memcpy(buffer + i + 1, unicode_utf8 + i, len - i); buffer[i] = '\0'; buffer[len + 1] = '\n'; buffer[len + 2] = '\0'; @@ -360,8 +360,8 @@ TEST(Utf8ChunkBoundaries) { for (size_t i = 1; i < len; i++) { // Copy source string into buffer, splitting it at i. // Then add three chunks, 0..i-1, i..strlen-1, empty. - strncpy(buffer, unicode_utf8, i); - strncpy(buffer + i + 1, unicode_utf8 + i, len - i); + memcpy(buffer, unicode_utf8, i); + memcpy(buffer + i + 1, unicode_utf8 + i, len - i); buffer[i] = '\0'; buffer[len + 1] = '\0'; buffer[len + 2] = '\0';