diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-04-17 10:57:43 -0400 |
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-04-17 10:57:43 -0400 |
| commit | 90cbf865cb6e88d5db6484040dc4dc885f88caed (patch) | |
| tree | ae587578f48a9cc5c307d0d8d7485947428aa708 /src/cli | |
| parent | d17103f326bbf026f55a326629e41e69c21a78ad (diff) | |
| download | stasis-90cbf865cb6e88d5db6484040dc4dc885f88caed.tar.gz | |
Convert vsprintf
* Check error conditions in related v-functions
Diffstat (limited to 'src/cli')
| -rw-r--r-- | src/cli/stasis_indexer/helpers.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/cli/stasis_indexer/helpers.c b/src/cli/stasis_indexer/helpers.c index 2ecdc74..0debfe4 100644 --- a/src/cli/stasis_indexer/helpers.c +++ b/src/cli/stasis_indexer/helpers.c @@ -243,7 +243,15 @@ int get_files(struct StrList **out, const char *path, const char *pattern, ...) va_list args; va_start(args, pattern); char userpattern[PATH_MAX] = {0}; - vsprintf(userpattern, pattern, args); + const int len = vsnprintf(userpattern, sizeof(userpattern), pattern, args); + if (len < 0) { + SYSERROR("%s", "vsnprintf failed\n"); + va_end(args); + return -1; + } + if ((size_t) len > sizeof(userpattern)) { + fprintf(stderr, "WARNING: %s: userpattern truncated!\n", __FUNCTION__); + } va_end(args); if (!strlen(userpattern)) { userpattern[0] = '*'; |
