diff options
author | Ken McDonell <kenj@kenj.id.au> | 2024-02-05 12:07:01 +1100 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2024-02-05 22:24:46 +0100 |
commit | fdbb0629bc4cf21c1ad8d1c353a4d015b2816cbd (patch) | |
tree | 65971aeef35df12893d38f5d14186b795e1333bd | |
parent | 541c17c975bc8a4f1f243e568006b0e26ae52c47 (diff) |
Minor bug fixes for Coverity issues
Over in the PCP project, Coverity has spotted a couple of minor
issues in the htop code.
This commit addresses them:
Settings.c
need to take control of the umask before calling mkstemp()
pcp/Platform.c
Although Platform_getMaxPid() returns a pid_t (which
strictly speaking is signed), the value is used to call
Row_setPidColumnWidth() and a negative value here is not good
... using INT_MAX instead of UNIT_MAX on the (unlikely) error
path makes no practical difference but may keep Coverity quiet
-rw-r--r-- | Settings.c | 3 | ||||
-rw-r--r-- | pcp/Platform.c | 2 |
2 files changed, 4 insertions, 1 deletions
@@ -622,8 +622,11 @@ int Settings_write(const Settings* this, bool onCrash) { fd = stderr; separator = ';'; } else { + /* create tempfile with mode 0600 */ + mode_t cur_umask = umask(S_IXUSR | S_IRWXG | S_IRWXO); xAsprintf(&tmpFilename, "%s.tmp.XXXXXX", this->filename); int fdtmp = mkstemp(tmpFilename); + umask(cur_umask); if (fdtmp == -1) return -errno; fd = fdopen(fdtmp, "w"); diff --git a/pcp/Platform.c b/pcp/Platform.c index 0b5f3344..d50edd25 100644 --- a/pcp/Platform.c +++ b/pcp/Platform.c @@ -480,7 +480,7 @@ pid_t Platform_getMaxPid(void) { pmAtomValue value; if (Metric_values(PCP_PID_MAX, &value, 1, PM_TYPE_32) == NULL) - return UINT_MAX; + return INT_MAX; pcp->pidmax = value.l; return pcp->pidmax; } |