]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
log: do not pass negative fd to fchown
authorSage Weil <sage@redhat.com>
Mon, 14 Mar 2016 16:50:33 +0000 (12:50 -0400)
committerSage Weil <sage@redhat.com>
Mon, 14 Mar 2016 16:50:33 +0000 (12:50 -0400)
>>>     CID 1355574:  Error handling issues  (NEGATIVE_RETURNS)
>>>     "this->m_fd" is passed to a parameter that cannot be negative.

Signed-off-by: Sage Weil <sage@redhat.com>
src/log/Log.cc

index bf46e20c7cf60fd6650d6a0fb157a5b0c50fa94f..29e0529e89995523fd5ed3bb1532dad5ec5a8627 100644 (file)
@@ -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;