Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions include/fluent-bit/flb_glob_win32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/* Fluent Bit
* ==========
* Copyright (C) 2015-2024 The Fluent Bit Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef FLB_GLOB_WIN32_H
#define FLB_GLOB_WIN32_H

#include <fluent-bit/flb_info.h>
#include <sys/stat.h>
#include <limits.h>

#ifdef FLB_SYSTEM_WINDOWS

#include <cfl/cfl_list.h>

#define FLB_FILE_GLOB_ABORT_ON_ERROR (((uint64_t) 1) << 0)
#define FLB_FILE_GLOB_MARK_DIRECTORIES (((uint64_t) 1) << 1)
#define FLB_FILE_GLOB_DO_NOT_SORT (((uint64_t) 1) << 2)
#define FLB_FILE_GLOB_EXPAND_TILDE (((uint64_t) 1) << 3)

#define FLB_FILE_GLOB_ERROR_SUCCESS 0
#define FLB_FILE_GLOB_ERROR_ABORTED 1
#define FLB_FILE_GLOB_ERROR_NO_MEMORY 2
#define FLB_FILE_GLOB_ERROR_NO_FILE 3
#define FLB_FILE_GLOB_ERROR_NO_ACCESS 4
#define FLB_FILE_GLOB_ERROR_NO_MATCHES 5
#define FLB_FILE_GLOB_ERROR_NO_MORE_RESULTS 6
#define FLB_FILE_GLOB_ERROR_OVERSIZED_PATH 7
#define FLB_FILE_GLOB_ERROR_INVALID_ARGUMENT 8

#ifndef GLOB_NOSPACE
#define GLOB_NOSPACE FLB_FILE_GLOB_ERROR_NO_MEMORY
#endif

#ifndef GLOB_ABORTED
#define GLOB_ABORTED FLB_FILE_GLOB_ERROR_ABORTED
#endif

#ifndef GLOB_NOMATCH
#define GLOB_NOMATCH FLB_FILE_GLOB_ERROR_NO_MATCHES
#endif

#ifndef GLOB_ERR
#define GLOB_ERR FLB_FILE_GLOB_ABORT_ON_ERROR
#endif

#define FLB_FILE_MAX_PATH_LENGTH PATH_MAX

struct flb_file_glob_inner_entry {
char *path;
struct cfl_list _head;
};

struct flb_file_glob_inner_context {
struct flb_file_glob_inner_entry *current_entry;
struct cfl_list results;
size_t entries;
size_t index;
uint64_t flags;
};

struct flb_file_glob_context {
struct flb_file_glob_inner_context *inner_context;
uint64_t flags;
char *path;
};

typedef struct {
struct flb_file_glob_context inner_context;
char **gl_pathv;
size_t gl_pathc;
} glob_t;

int glob(const char *path, uint64_t flags, void *unused, glob_t *context);
void globfree(glob_t *context);
int is_directory(char *path, struct stat *fs_entry_metadata);


#endif /* FLB_SYSTEM_WINDOWS */
#endif /* FLB_GLOB_WIN32_H */
4 changes: 3 additions & 1 deletion plugins/in_blob/blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
#include "blob_db.h"
#include "blob_file.h"

#include "win32_glob.c"
#ifdef FLB_SYSTEM_WINDOWS
#include <fluent-bit/flb_glob_win32.h>
#endif

/* Define missing GLOB_TILDE if not exists */
#ifndef GLOB_TILDE
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ if(FLB_SYSTEM_WINDOWS)
set(src
${src}
flb_dlfcn_win32.c
win32/flb_glob.c
)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W2")
endif()
Expand Down
86 changes: 14 additions & 72 deletions plugins/in_blob/win32_glob.c → src/win32/flb_glob.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* limitations under the License.
*/

#if defined(FLB_SYSTEM_WINDOWS) && !defined(FLB_FILE_GLOB_ERROR_SUCCESS)
#if defined(FLB_SYSTEM_WINDOWS)

#include <fluent-bit/flb_info.h>
#include <fluent-bit/flb_file.h>
Expand All @@ -28,73 +28,14 @@
#include <fluent-bit/flb_str.h>
#include <cfl/cfl.h>
#include <cfl/cfl_list.h>
#include <fluent-bit/flb_glob_win32.h>

#include <lmaccess.h>
#include <sys/stat.h>
#include <stdio.h>

#define FLB_FILE_GLOB_ABORT_ON_ERROR (((uint64_t) 1) << 0)
#define FLB_FILE_GLOB_MARK_DIRECTORIES (((uint64_t) 1) << 1)
#define FLB_FILE_GLOB_DO_NOT_SORT (((uint64_t) 1) << 2)
#define FLB_FILE_GLOB_EXPAND_TILDE (((uint64_t) 1) << 3)

#define FLB_FILE_GLOB_ERROR_SUCCESS 0
#define FLB_FILE_GLOB_ERROR_ABORTED 1
#define FLB_FILE_GLOB_ERROR_NO_MEMORY 2
#define FLB_FILE_GLOB_ERROR_NO_FILE 3
#define FLB_FILE_GLOB_ERROR_NO_ACCESS 4
#define FLB_FILE_GLOB_ERROR_NO_MATCHES 5
#define FLB_FILE_GLOB_ERROR_NO_MORE_RESULTS 6
#define FLB_FILE_GLOB_ERROR_OVERSIZED_PATH 7
#define FLB_FILE_GLOB_ERROR_INVALID_ARGUMENT 8

#ifndef GLOB_NOSPACE
#define GLOB_NOSPACE FLB_FILE_GLOB_ERROR_NO_MEMORY
#endif

#ifndef GLOB_ABORTED
#define GLOB_ABORTED FLB_FILE_GLOB_ERROR_ABORTED
#endif

#ifndef GLOB_NOMATCH
#define GLOB_NOMATCH FLB_FILE_GLOB_ERROR_NO_MATCHES
#endif

#ifndef GLOB_ERR
#define GLOB_ERR FLB_FILE_GLOB_ABORT_ON_ERROR
#endif

#define FLB_FILE_MAX_PATH_LENGTH PATH_MAX

#define FLB_FILE_ISTYPE(m, t) (((m) & 0170000) == t)

struct flb_file_glob_inner_entry {
char *path;
struct cfl_list _head;
};

struct flb_file_glob_inner_context {
struct flb_file_glob_inner_entry *current_entry;
struct cfl_list results;
size_t entries;
size_t index;
uint64_t flags;
};

struct flb_file_glob_context {
struct flb_file_glob_inner_context *inner_context;
uint64_t flags;
char *path;
};

struct glob_t {
struct flb_file_glob_context inner_context;
char **gl_pathv;
size_t gl_pathc;
};

typedef struct glob_t glob_t;

static int flb_file_glob_start(struct flb_file_glob_context *context,
const char *path,
uint64_t flags);
Expand All @@ -104,7 +45,7 @@ static void flb_file_glob_clean(struct flb_file_glob_context *context);
static int flb_file_glob_fetch(struct flb_file_glob_context *context,
char **result);

static void globfree(glob_t *context)
void globfree(glob_t *context)
{
size_t index;

Expand All @@ -116,7 +57,7 @@ static void globfree(glob_t *context)
flb_file_glob_clean(&context->inner_context);
}

static int glob(const char *path,
int glob(const char *path,
uint64_t flags,
void *unused,
glob_t *context)
Expand All @@ -127,7 +68,7 @@ static int glob(const char *path,

(void) unused;

result = flb_file_glob_start(context, path, flags);
result = flb_file_glob_start(&context->inner_context, path, flags);

if (result == FLB_FILE_GLOB_ERROR_SUCCESS) {
entries = cfl_list_size(&context->inner_context.inner_context->results);
Expand All @@ -150,14 +91,15 @@ static int glob(const char *path,
return result;
}
}
context->gl_pathc = entries;
}

return result;
}

static int is_directory(char *path, struct stat *fs_entry_metadata)
int is_directory(char *path, struct stat *fs_entry_metadata)
{
return (fs_entry_metadata->st_mode & S_IFDIR != 0);
return ((fs_entry_metadata->st_mode & S_IFDIR) != 0);
}
Comment on lines +100 to 103
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

find . -name "flb_glob.c" -type f

Repository: fluent/fluent-bit

Length of output: 83


🌐 Web query:

MSVC Windows stat.h S_IFDIR S_ISDIR macro definition st_mode directory check

💡 Result:

On MSVC/Windows, <sys/stat.h> exposes the file-type bits mainly as underscore-prefixed constants (for _stat::st_mode), e.g. _S_IFMT (type mask) and _S_IFDIR (directory). The usual directory test is: (st.st_mode & _S_IFMT) == _S_IFDIR. [1]

MSVC typically does not provide POSIX S_ISDIR() (nor S_ISREG()), so you either:

  • use the mask test directly, or
  • define the macro yourself (POSIX-style):
    #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) [2][3]

If you want the non-underscore names S_IFMT, S_IFDIR, etc. from MSVC’s headers, define this before including <sys/stat.h>:

`#define` _CRT_INTERNAL_NONSTDC_NAMES 1
`#include` <sys/stat.h>

Then you can use the POSIX-style macro definitions above. [2]

Minimal MSVC-compatible directory check:

`#include` <sys/stat.h>

int is_dir(const struct _stat* st) {
  return (st->st_mode & _S_IFMT) == _S_IFDIR;
}
``` [1]

References:  
[1] Microsoft `_stat` `st_mode` constants (`_S_IFMT`, `_S_IFDIR`, etc.)  
[2] MSVC note/workaround: `_CRT_INTERNAL_NONSTDC_NAMES` and defining `S_ISDIR`  
[3] POSIX definition/intent of `S_ISDIR(m)` checking `st_mode`

---

🏁 Script executed:

```shell
cat -n ./src/win32/flb_glob.c | head -120 | tail -50

Repository: fluent/fluent-bit

Length of output: 1640


🏁 Script executed:

cat -n ./src/win32/flb_glob.c | head -20

Repository: fluent/fluent-bit

Length of output: 979


🏁 Script executed:

cat -n ./src/win32/flb_glob.c | head -50

Repository: fluent/fluent-bit

Length of output: 2031


🏁 Script executed:

rg "S_ISDIR|_CRT_INTERNAL_NONSTDC_NAMES" src/win32/

Repository: fluent/fluent-bit

Length of output: 43


🏁 Script executed:

rg "FLB_FILE_ISTYPE" src/win32/flb_glob.c -A 2 -B 2

Repository: fluent/fluent-bit

Length of output: 380


Use proper file type masking for directory checks: (st_mode & S_IFMT) == S_IFDIR or the existing FLB_FILE_ISTYPE macro.

The current check (st_mode & S_IFDIR) != 0 is unsafe—it tests a single bit without masking the type field first, which can incorrectly match other file types if their bits overlap with S_IFDIR. The correct approach is to mask with S_IFMT (file type field) before comparing. Since this is Windows-specific code, S_ISDIR() is not available in MSVC's standard library; use (st_mode & S_IFMT) == S_IFDIR instead, or leverage the FLB_FILE_ISTYPE(st_mode, S_IFDIR) macro already defined in this file (line 37).

🛠️ Suggested fix
-    return ((fs_entry_metadata->st_mode & S_IFDIR) != 0);
+    return FLB_FILE_ISTYPE(fs_entry_metadata->st_mode, S_IFDIR);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
int is_directory(char *path, struct stat *fs_entry_metadata)
{
return (fs_entry_metadata->st_mode & S_IFDIR != 0);
return ((fs_entry_metadata->st_mode & S_IFDIR) != 0);
}
int is_directory(char *path, struct stat *fs_entry_metadata)
{
return FLB_FILE_ISTYPE(fs_entry_metadata->st_mode, S_IFDIR);
}
🤖 Prompt for AI Agents
In `@src/win32/flb_glob.c` around lines 100 - 103, The is_directory function
currently tests file type incorrectly by using (fs_entry_metadata->st_mode &
S_IFDIR) != 0; update is_directory to mask the type field first and compare to
S_IFDIR (e.g. (fs_entry_metadata->st_mode & S_IFMT) == S_IFDIR) or use the
existing FLB_FILE_ISTYPE(fs_entry_metadata->st_mode, S_IFDIR) macro defined
earlier in the file; modify the return expression in is_directory to use one of
these proper checks so directory detection is correct on Windows/MSVC.


static void reset_errno()
Expand Down Expand Up @@ -485,9 +427,9 @@ static int limited_win32_glob(struct flb_file_glob_inner_context *context,
return ret;
}

int flb_file_glob_start(struct flb_file_glob_context *context,
const char *path,
uint64_t flags)
static int flb_file_glob_start(struct flb_file_glob_context *context,
const char *path,
uint64_t flags)
{

int tilde_expansion_attempted;
Expand Down Expand Up @@ -528,7 +470,7 @@ int flb_file_glob_start(struct flb_file_glob_context *context,
context->path);
}

void flb_file_glob_clean(struct flb_file_glob_context *context)
static void flb_file_glob_clean(struct flb_file_glob_context *context)
{
struct cfl_list *iterator_backup;
struct cfl_list *iterator;
Expand Down Expand Up @@ -564,8 +506,8 @@ void flb_file_glob_clean(struct flb_file_glob_context *context)

}

int flb_file_glob_fetch(struct flb_file_glob_context *context,
char **result)
static int flb_file_glob_fetch(struct flb_file_glob_context *context,
char **result)
{

if (context == NULL) {
Expand Down
7 changes: 7 additions & 0 deletions tests/internal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ if(FLB_HAVE_LIBYAML)
)
endif()

if (WIN32)
set(UNIT_TESTS_FILES
${UNIT_TESTS_FILES}
win32_glob.c
)
endif()

if (NOT WIN32)
set(UNIT_TESTS_FILES
${UNIT_TESTS_FILES}
Expand Down
74 changes: 74 additions & 0 deletions tests/internal/win32_glob.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#include <fluent-bit/flb_info.h>
#include <fluent-bit/flb_mem.h>
#include <fluent-bit/flb_str.h>
#include "flb_tests_internal.h"

#ifdef FLB_SYSTEM_WINDOWS
#include <fluent-bit/flb_glob_win32.h>

void test_glob_basic()
{
glob_t glob_data;
int ret;
FILE *fp;

/* Create some dummy files */
fp = fopen("test_glob_1.txt", "w");
if (fp) fclose(fp);
fp = fopen("test_glob_2.txt", "w");
if (fp) fclose(fp);
Comment on lines +16 to +19
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add error handling for file creation.

If fopen fails, the test proceeds and may not find the expected 2 files, causing a misleading test failure. Consider failing the test early if file creation fails.

Proposed fix
     /* Create some dummy files */
     fp = fopen("test_glob_1.txt", "w");
-    if (fp) fclose(fp);
+    TEST_CHECK(fp != NULL);
+    if (fp) fclose(fp);
     fp = fopen("test_glob_2.txt", "w");
-    if (fp) fclose(fp);
+    TEST_CHECK(fp != NULL);
+    if (fp) fclose(fp);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fp = fopen("test_glob_1.txt", "w");
if (fp) fclose(fp);
fp = fopen("test_glob_2.txt", "w");
if (fp) fclose(fp);
fp = fopen("test_glob_1.txt", "w");
TEST_CHECK(fp != NULL);
if (fp) fclose(fp);
fp = fopen("test_glob_2.txt", "w");
TEST_CHECK(fp != NULL);
if (fp) fclose(fp);
🤖 Prompt for AI Agents
In `@tests/internal/win32_glob.c` around lines 16 - 19, The test currently calls
fopen for "test_glob_1.txt" and "test_glob_2.txt" into variable fp but does not
handle fopen returning NULL; update the test to check fp after each fopen, and
if fp == NULL emit a clear error (e.g., perror or fprintf to stderr with the
filename) and fail the test early (exit/return non-zero or call the test
framework's fail helper), and only call fclose when fp is non-NULL; ensure both
file creations are checked separately so a single failure stops the test instead
of producing misleading results.


ret = glob("test_glob_*.txt", 0, NULL, &glob_data);
TEST_CHECK(ret == 0);
TEST_CHECK(glob_data.gl_pathc == 2);

globfree(&glob_data);

/* Cleanup */
unlink("test_glob_1.txt");
unlink("test_glob_2.txt");
}
Comment on lines +9 to +30
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Missing initialization for glob_data struct.

In test_glob_basic, the glob_data variable is declared without initialization (line 11), unlike test_glob_nomatch which initializes with {0} (line 34). This could lead to undefined behavior if the glob implementation doesn't fully initialize all struct members.

Apply this diff to initialize the struct:

 void test_glob_basic()
 {
-    glob_t glob_data;
+    glob_t glob_data = {0};
     int ret;
     FILE *fp;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
void test_glob_basic()
{
glob_t glob_data;
int ret;
FILE *fp;
/* Create some dummy files */
fp = fopen("test_glob_1.txt", "w");
if (fp) fclose(fp);
fp = fopen("test_glob_2.txt", "w");
if (fp) fclose(fp);
ret = glob("test_glob_*.txt", 0, NULL, &glob_data);
TEST_CHECK(ret == 0);
TEST_CHECK(glob_data.gl_pathc == 2);
globfree(&glob_data);
/* Cleanup */
unlink("test_glob_1.txt");
unlink("test_glob_2.txt");
}
void test_glob_basic()
{
glob_t glob_data = {0};
int ret;
FILE *fp;
/* Create some dummy files */
fp = fopen("test_glob_1.txt", "w");
if (fp) fclose(fp);
fp = fopen("test_glob_2.txt", "w");
if (fp) fclose(fp);
ret = glob("test_glob_*.txt", 0, NULL, &glob_data);
TEST_CHECK(ret == 0);
TEST_CHECK(glob_data.gl_pathc == 2);
globfree(&glob_data);
/* Cleanup */
unlink("test_glob_1.txt");
unlink("test_glob_2.txt");
}
🤖 Prompt for AI Agents
In tests/internal/win32_glob.c around lines 9 to 30, the local variable
glob_data is declared uninitialized which can cause undefined behavior; change
its declaration to zero-initialize the struct (e.g., declare glob_t glob_data =
{0}; or otherwise zero it before use) so all members are defined prior to
calling glob(), keeping the rest of the test (glob call, checks, globfree and
cleanup) unchanged.


void test_glob_nomatch()
{
glob_t glob_data = {0};
int ret;

ret = glob("non_existent_*.txt", 0, NULL, &glob_data);
TEST_CHECK(ret == GLOB_NOMATCH);

globfree(&glob_data);
}

void test_glob_wildcard()
{
glob_t glob_data;
int ret;
FILE *fp;

/* Create dummy file */
fp = fopen("test_wildcard.txt", "w");
if (fp) fclose(fp);
Comment on lines +50 to +51
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add error handling for file creation.

Same issue as test_glob_basic - if fopen fails, the test will produce misleading results.

Proposed fix
     /* Create dummy file */
     fp = fopen("test_wildcard.txt", "w");
+    TEST_CHECK(fp != NULL);
     if (fp) fclose(fp);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fp = fopen("test_wildcard.txt", "w");
if (fp) fclose(fp);
fp = fopen("test_wildcard.txt", "w");
TEST_CHECK(fp != NULL);
if (fp) fclose(fp);
🤖 Prompt for AI Agents
In `@tests/internal/win32_glob.c` around lines 50 - 51, The fopen call that
creates "test_wildcard.txt" uses fp without checking for failure (fp =
fopen(...); if (fp) fclose(fp);), which can yield misleading test outcomes;
update tests/internal/win32_glob.c to check for fp == NULL after fopen and
handle the error (e.g., call perror or the test harness failure/ASSERT/return)
instead of silently continuing, mirroring the fix used in test_glob_basic so the
test aborts or records a clear failure if the file cannot be created.


ret = glob("test_wild*.txt", 0, NULL, &glob_data);
TEST_CHECK(ret == 0);
TEST_CHECK(glob_data.gl_pathc == 1);
if (glob_data.gl_pathc > 0) {
TEST_CHECK(strstr(glob_data.gl_pathv[0], "test_wildcard.txt") != NULL);
}

globfree(&glob_data);
unlink("test_wildcard.txt");
}
Comment on lines +43 to +62
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Same initialization concern in test_glob_wildcard.

Similar to test_glob_basic, the glob_data variable is not initialized.

Apply this diff:

 void test_glob_wildcard()
 {
-    glob_t glob_data;
+    glob_t glob_data = {0};
     int ret;
     FILE *fp;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
void test_glob_wildcard()
{
glob_t glob_data;
int ret;
FILE *fp;
/* Create dummy file */
fp = fopen("test_wildcard.txt", "w");
if (fp) fclose(fp);
ret = glob("test_wild*.txt", 0, NULL, &glob_data);
TEST_CHECK(ret == 0);
TEST_CHECK(glob_data.gl_pathc == 1);
if (glob_data.gl_pathc > 0) {
TEST_CHECK(strstr(glob_data.gl_pathv[0], "test_wildcard.txt") != NULL);
}
globfree(&glob_data);
unlink("test_wildcard.txt");
}
void test_glob_wildcard()
{
glob_t glob_data = {0};
int ret;
FILE *fp;
/* Create dummy file */
fp = fopen("test_wildcard.txt", "w");
if (fp) fclose(fp);
ret = glob("test_wild*.txt", 0, NULL, &glob_data);
TEST_CHECK(ret == 0);
TEST_CHECK(glob_data.gl_pathc == 1);
if (glob_data.gl_pathc > 0) {
TEST_CHECK(strstr(glob_data.gl_pathv[0], "test_wildcard.txt") != NULL);
}
globfree(&glob_data);
unlink("test_wildcard.txt");
}
🤖 Prompt for AI Agents
In tests/internal/win32_glob.c around lines 43 to 62, the local variable
glob_data is used without being initialized; initialize it before calling glob
(either declare as "glob_t glob_data = {0};" or call memset(&glob_data, 0,
sizeof glob_data);) so globfree can safely be called and gl_pathc/gl_pathv have
defined initial values.


TEST_LIST = {
{ "basic", test_glob_basic },
{ "nomatch", test_glob_nomatch },
{ "wildcard", test_glob_wildcard },
{ 0 }
};
#else
TEST_LIST = {
{ 0 }
};
#endif
Loading