Skip to content

Commit

Permalink
utils: validate allocation before filling with GUID on windows.
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Whelan <phil@calyptia.com>
  • Loading branch information
pwhelan authored and edsiper committed Aug 27, 2024
1 parent 122f99b commit 03f595b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/flb_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1415,12 +1415,13 @@ int flb_utils_get_machine_id(char **out_id, size_t *out_size)

if (status == ERROR_SUCCESS) {
*out_id = flb_calloc(1, dwBufSize+1);
memcpy(*out_id, buf, dwBufSize);

if (*out_id == NULL) {
return -1;
}

memcpy(*out_id, buf, dwBufSize);

/* RegQueryValueEx sets dwBufSize to strlen()+1 for the NULL
* terminator, but we only need strlen(). */
*out_size = dwBufSize-1;
Expand Down

0 comments on commit 03f595b

Please sign in to comment.