Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 8cc2d86

Browse files
author
William Douglas
committed
Fix buffer size for inmemory version
When allocating the buffer for a version string, the size should be one greater than the max string size as the null string is inserted at the content size index which leads to a buffer overflow. Signed-off-by: William Douglas <[email protected]>
1 parent abea281 commit 8cc2d86

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/swupd_lib/version.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
int get_int_from_url(const char *url)
3636
{
3737
int err, value;
38-
char tmp_string[MAX_VERSION_STR_SIZE];
38+
char tmp_string[MAX_VERSION_STR_SIZE+1];
3939
struct curl_file_data tmp_data = {
4040
MAX_VERSION_STR_SIZE, 0,
4141
tmp_string
@@ -149,10 +149,9 @@ static int verify_signature(char *url, struct curl_file_data *tmp_version)
149149

150150
static int get_version_from_url(char *url)
151151
{
152-
153152
int ret = 0;
154153
int err = 0;
155-
char version_str[MAX_VERSION_STR_SIZE];
154+
char version_str[MAX_VERSION_STR_SIZE+1];
156155
int sig_verified = 0;
157156

158157
/* struct for version data */

0 commit comments

Comments
 (0)