1
0
Эх сурвалжийг харах

Bug 610281 - fix coverity Defect Type: Control flow issues - daemon.c:write_function()

https://bugzilla.redhat.com/show_bug.cgi?id=610281
Resolves: bug 610281
Bug Description: fix coverity Defect Type: Control flow issues - daemon.c:write_function()
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: sentbytes < count is ok in the non error case - it just means
we need to send some more data.  Move the checking to the error case so we
can print the number of bytes sent and expected.
Platforms tested: RHEL5 x86_64, Fedora 14 x86_64
Flag Day: no
Doc impact: no
Rich Megginson 15 жил өмнө
parent
commit
9174cc6158

+ 5 - 6
ldap/servers/slapd/daemon.c

@@ -1712,6 +1712,11 @@ write_function( int ignore, const void *buffer, int count, struct lextiof_socket
                     LDAPDebug(LDAP_DEBUG_ANY, "PR_Write(%d) "
                               SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n",
                               fd, prerr, slapd_pr_strerror( prerr ));
+                    if (sentbytes < count) {
+                        LDAPDebug(LDAP_DEBUG_CONNS,
+                                  "PR_Write(%d) - wrote only %d bytes (expected %d bytes) - 0 (EOF)\n", /* disconnected */
+                                  fd, sentbytes, count);
+                    }
                     break;		/* fatal error */
                 }
             } else if (bytes == 0) { /* disconnect */
@@ -1731,12 +1736,6 @@ write_function( int ignore, const void *buffer, int count, struct lextiof_socket
                           fd, sentbytes, count);
                 PR_SetError(PR_BUFFER_OVERFLOW_ERROR, EMSGSIZE);
                 break;
-            } else if (sentbytes < count) {
-                LDAPDebug(LDAP_DEBUG_CONNS,
-                          "PR_Write(%d) - wrote only %d bytes (expected %d bytes) - 0 (EOF)\n", /* disconnected */
-                          fd, sentbytes, count);
-                PR_SetError(PR_PIPE_ERROR, EPIPE);
-                break;
             }
         }
     }