diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-09-20 08:45:20 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-09-20 13:11:45 -0400 |
commit | 0de2a305fc2187f62b3df36d7541e7f4fa254f61 (patch) | |
tree | 56381c78c4d78bf7ef2c4193f4725cb6ecc5f9e2 /src/utils.c | |
parent | d76321976cfe42bb03b5e7e48ac9f6d95d97b14a (diff) | |
download | stasis-0de2a305fc2187f62b3df36d7541e7f4fa254f61.tar.gz |
Fix string op warnings
* Fix unused-result warnings
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/utils.c b/src/utils.c index c0b3733..63c0cb7 100644 --- a/src/utils.c +++ b/src/utils.c @@ -34,7 +34,7 @@ int popd() { int rmtree(char *_path) { int status = 0; char path[PATH_MAX] = {0}; - strncpy(path, _path, sizeof(path)); + strncpy(path, _path, sizeof(path) - 1); DIR *dir; struct dirent *d_entity; @@ -122,10 +122,10 @@ char *expandpath(const char *_path) { } // Construct the new path - strncat(result, home, PATH_MAX - 1); + strncat(result, home, sizeof(result) - strlen(home) + 1); if (sep) { - strncat(result, DIR_SEP, PATH_MAX - 1); - strncat(result, ptmp, PATH_MAX - 1); + strncat(result, DIR_SEP, sizeof(result) - strlen(home) + 1); + strncat(result, ptmp, sizeof(result) - strlen(home) + 1); } return strdup(result); @@ -444,7 +444,10 @@ void msg(unsigned type, char *fmt, ...) { void debug_shell() { msg(STASIS_MSG_L1 | STASIS_MSG_WARN, "ENTERING STASIS DEBUG SHELL\n" STASIS_COLOR_RESET); - system("/bin/bash -c 'PS1=\"(STASIS DEBUG) \\W $ \" bash --norc --noprofile'"); + if (system("/bin/bash -c 'PS1=\"(STASIS DEBUG) \\W $ \" bash --norc --noprofile'") < 0) { + SYSERROR("unable to spawn debug shell: %s", strerror(errno)); + exit(errno); + } msg(STASIS_MSG_L1 | STASIS_MSG_WARN, "EXITING STASIS DEBUG SHELL\n" STASIS_COLOR_RESET); exit(255); } |