From d494beffd5fd92ff3659d9c99da172ebecc1bf3e Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Fri, 9 Aug 2024 16:13:20 -0400 Subject: [PATCH] utils: validate allocation before filling with GUID on windows. Signed-off-by: Phillip Whelan --- src/flb_utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/flb_utils.c b/src/flb_utils.c index 3761ad2cadc..7c287de05e4 100644 --- a/src/flb_utils.c +++ b/src/flb_utils.c @@ -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;