Skip to content

Commit

Permalink
deps: V8: cherry-pick e1eac1b16c96
Browse files Browse the repository at this point in the history
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 <ahaas@chromium.org>
    Reviewed-by: Toon Verwaest <verwaest@chromium.org>
    Commit-Queue: Milad Farazmand <miladfar@ca.ibm.com>
    Cr-Commit-Position: refs/heads/master@{#67277}

Refs: v8/v8@e1eac1b

PR-URL: #32974
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
  • Loading branch information
Milad Farazmand authored and BethGriggs committed Apr 28, 2020
1 parent 7647860 commit bbed1e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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 #####

Expand Down
8 changes: 4 additions & 4 deletions deps/v8/test/cctest/parsing/test-scanner-streams.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit bbed1e5

Please sign in to comment.