Skip to content

Commit af1dac9

Browse files
authored
Merge pull request #866 from JacobBarthelmeh/warninigs
fix for warning with snprintf use in test case
2 parents ea563b5 + 069dcc0 commit af1dac9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

apps/wolfsshd/test/test_configuration.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ static void CleanupWildcardTest(void)
3131
WDIR dir;
3232
struct dirent* d;
3333
char filepath[MAX_PATH*2]; /* d_name is max_path long */
34+
size_t prefixLen;
35+
size_t maxNameLen;
3436

37+
prefixLen = WSTRLEN("./sshd_config.d/");
38+
maxNameLen = sizeof(filepath) - prefixLen - 1; /* -1 for null terminator */
3539
if (!WOPENDIR(NULL, NULL, &dir, "./sshd_config.d/")) {
3640
while ((d = WREADDIR(NULL, &dir)) != NULL) {
3741
#if defined(__QNX__) || defined(__QNXNTO__)
@@ -43,8 +47,9 @@ static void CleanupWildcardTest(void)
4347
if (d->d_type != DT_DIR)
4448
#endif
4549
{
46-
WSNPRINTF(filepath, sizeof filepath, "%s%s",
47-
"./sshd_config.d/", d->d_name);
50+
WSNPRINTF(filepath, sizeof filepath, "%.*s%.*s",
51+
(int)prefixLen, "./sshd_config.d/",
52+
(int)maxNameLen, d->d_name);
4853
WREMOVE(0, filepath);
4954
}
5055
}

0 commit comments

Comments
 (0)