Skip to content

Commit

Permalink
log: do not pass negative fd to fchown
Browse files Browse the repository at this point in the history
>>>     CID 1355574:  Error handling issues  (NEGATIVE_RETURNS)
>>>     "this->m_fd" is passed to a parameter that cannot be negative.

Signed-off-by: Sage Weil <[email protected]>
  • Loading branch information
liewegas committed Mar 14, 2016
1 parent cc7e232 commit 9ed77c8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/log/Log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void Log::reopen_log_file()
VOID_TEMP_FAILURE_RETRY(::close(m_fd));
if (m_log_file.length()) {
m_fd = ::open(m_log_file.c_str(), O_CREAT|O_WRONLY|O_APPEND, 0644);
if (m_uid || m_gid) {
if (m_fd >= 0 && (m_uid || m_gid)) {
int r = ::fchown(m_fd, m_uid, m_gid);
if (r < 0) {
r = -errno;
Expand Down

0 comments on commit 9ed77c8

Please sign in to comment.