Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a5d63f9

Browse filesBrowse files
Xstouditargos
authored andcommitted
buffer: use size_t instead of uint32_t to avoid segmentation fault
Fixes: #46836 PR-URL: #48033 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Shelley Vohr <shelley.vohr@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
1 parent 75004d3 commit a5d63f9
Copy full SHA for a5d63f9

File tree

Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed
Open diff view settings
Collapse file

‎src/string_bytes.cc‎

Copy file name to clipboardExpand all lines: src/string_bytes.cc
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -627,11 +627,11 @@ size_t StringBytes::hex_encode(
627627
char* dst,
628628
size_t dlen) {
629629
// We know how much we'll write, just make sure that there's space.
630-
CHECK(dlen >= slen * 2 &&
631-
"not enough space provided for hex encode");
630+
CHECK(dlen >= MultiplyWithOverflowCheck<size_t>(slen, 2u) &&
631+
"not enough space provided for hex encode");
632632

633633
dlen = slen * 2;
634-
for (uint32_t i = 0, k = 0; k < dlen; i += 1, k += 2) {
634+
for (size_t i = 0, k = 0; k < dlen; i += 1, k += 2) {
635635
static const char hex[] = "0123456789abcdef";
636636
uint8_t val = static_cast<uint8_t>(src[i]);
637637
dst[k + 0] = hex[val >> 4];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.