* [olang/patches/.build.yml] build failed
2024-03-02 20:01 [PATCH olang] string_view: fix stack buffer overflow on to_u32 Johnny Richard
@ 2024-03-02 19:02 ` builds.sr.ht
2024-03-02 20:06 ` [PATCH olang] string_view: fix stack buffer overflow on to_u32 Johnny Richard
1 sibling, 0 replies; 4+ messages in thread
From: builds.sr.ht @ 2024-03-02 19:02 UTC (permalink / raw)
To: Johnny Richard; +Cc: ~johnnyrichard/olang-devel
olang/patches/.build.yml: FAILED in 36s
[string_view: fix stack buffer overflow on to_u32][0] from [Johnny Richard][1]
[0]: https://lists.sr.ht/~johnnyrichard/olang-devel/patches/49949
[1]: mailto:johnny@johnnyrichard.com
✗ #1160713 FAILED olang/patches/.build.yml https://builds.sr.ht/~johnnyrichard/job/1160713
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH olang] string_view: fix stack buffer overflow on to_u32
2024-03-02 20:06 ` [PATCH olang] string_view: fix stack buffer overflow on to_u32 Johnny Richard
@ 2024-03-02 19:18 ` Carlos Maniero
0 siblings, 0 replies; 4+ messages in thread
From: Carlos Maniero @ 2024-03-02 19:18 UTC (permalink / raw)
To: Johnny Richard, ~johnnyrichard/olang-devel
Thanks for the fix. Applied!
To git.sr.ht:~johnnyrichard/olang
2f0c54c..18ade2a main -> main
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH olang] string_view: fix stack buffer overflow on to_u32
@ 2024-03-02 20:01 Johnny Richard
2024-03-02 19:02 ` [olang/patches/.build.yml] build failed builds.sr.ht
2024-03-02 20:06 ` [PATCH olang] string_view: fix stack buffer overflow on to_u32 Johnny Richard
0 siblings, 2 replies; 4+ messages in thread
From: Johnny Richard @ 2024-03-02 20:01 UTC (permalink / raw)
To: ~johnnyrichard/olang-devel; +Cc: Johnny Richard
Signed-off-by: Johnny Richard <johnny@johnnyrichard.com>
---
src/string_view.c | 2 +-
tests/unit/string_view_test.c | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/string_view.c b/src/string_view.c
index 084f417..646dabd 100644
--- a/src/string_view.c
+++ b/src/string_view.c
@@ -40,7 +40,7 @@ uint32_t
string_view_to_u32(string_view_t str)
{
char ret[str.size + 1];
- ret[str.size + 1] = 0;
+ ret[str.size] = 0;
memcpy(ret, str.chars, str.size);
return atoi(ret);
}
diff --git a/tests/unit/string_view_test.c b/tests/unit/string_view_test.c
index 1d8627f..fe3dacb 100644
--- a/tests/unit/string_view_test.c
+++ b/tests/unit/string_view_test.c
@@ -48,6 +48,10 @@ string_view_to_u32_test(const MunitParameter params[], void *user_data_or_fixtur
assert_uint32(string_view_to_u32(str), ==, 69);
+ str = (string_view_t) { .chars = "39;", .size = 2 };
+
+ assert_uint32(string_view_to_u32(str), ==, 39);
+
return MUNIT_OK;
}
--
2.44.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH olang] string_view: fix stack buffer overflow on to_u32
2024-03-02 20:01 [PATCH olang] string_view: fix stack buffer overflow on to_u32 Johnny Richard
2024-03-02 19:02 ` [olang/patches/.build.yml] build failed builds.sr.ht
@ 2024-03-02 20:06 ` Johnny Richard
2024-03-02 19:18 ` Carlos Maniero
1 sibling, 1 reply; 4+ messages in thread
From: Johnny Richard @ 2024-03-02 20:06 UTC (permalink / raw)
To: ~johnnyrichard/olang-devel
Opss, lint problem. Fix it please...
----->8-----
Subject: [PATCH olang] fixup! string_view: fix stack buffer overflow on to_u32
diff --git a/tests/unit/string_view_test.c b/tests/unit/string_view_test.c
index fe3dacb..7a6776c 100644
--- a/tests/unit/string_view_test.c
+++ b/tests/unit/string_view_test.c
@@ -48,7 +48,7 @@ string_view_to_u32_test(const MunitParameter params[], void *user_data_or_fixtur
assert_uint32(string_view_to_u32(str), ==, 69);
- str = (string_view_t) { .chars = "39;", .size = 2 };
+ str = (string_view_t){ .chars = "39;", .size = 2 };
assert_uint32(string_view_to_u32(str), ==, 39);
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-03-02 19:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-02 20:01 [PATCH olang] string_view: fix stack buffer overflow on to_u32 Johnny Richard
2024-03-02 19:02 ` [olang/patches/.build.yml] build failed builds.sr.ht
2024-03-02 20:06 ` [PATCH olang] string_view: fix stack buffer overflow on to_u32 Johnny Richard
2024-03-02 19:18 ` Carlos Maniero
Code repositories for project(s) associated with this public inbox
https://git.johnnyrichard.com/olang.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox