summaryrefslogtreecommitdiffstats
path: root/ldap/servers/slapd/daemon.c
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@redhat.com>2010-07-08 11:28:42 -0700
committerNoriko Hosoi <nhosoi@redhat.com>2010-07-23 13:40:44 -0700
commit25dfa7cf81554e8795c8cb260f7493a94f59e6fb (patch)
tree3fbaf8b84bcce4fd712c2d1580121a9061f61ce1 /ldap/servers/slapd/daemon.c
parent00b81fed600b1ccef6bc87fcdaf562283e183002 (diff)
downloadds-25dfa7cf81554e8795c8cb260f7493a94f59e6fb.tar.gz
ds-25dfa7cf81554e8795c8cb260f7493a94f59e6fb.tar.xz
ds-25dfa7cf81554e8795c8cb260f7493a94f59e6fb.zip
610281 - fix coverity Defect Type: Control flow issues
https://bugzilla.redhat.com/show_bug.cgi?id=610281 11834 DEADCODE Triaged Unassigned Bug Minor Fix Required write_function() ds/ldap/servers/slapd/daemon.c Comment: The location of checking for sentbytes is not correct. Execution cannot reach this statement "if (sentbytes < count){ {...". 1724 } else if (sentbytes < count) { 1725 LDAPDebug(LDAP_DEBUG_CONNS, It should not be "else" of checking for "bytes". Moving the check after "else if (sentbytes > count)".
Diffstat (limited to 'ldap/servers/slapd/daemon.c')
-rw-r--r--ldap/servers/slapd/daemon.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index b523138b..783aaaed 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -1693,7 +1693,7 @@ write_function( int ignore, const void *buffer, int count, struct lextiof_socket
int fd = PR_FileDesc2NativeHandle((PRFileDesc *)handle);
if (handle == SLAPD_INVALID_SOCKET) {
- PR_SetError(PR_NOT_SOCKET_ERROR, EBADF);
+ PR_SetError(PR_NOT_SOCKET_ERROR, EBADF);
} else {
while (1) {
if (slapd_poll(handle, SLAPD_POLLOUT) < 0) { /* error */
@@ -1721,13 +1721,8 @@ write_function( int ignore, const void *buffer, int count, struct lextiof_socket
fd, prerr, slapd_pr_strerror(prerr));
PR_SetError(PR_PIPE_ERROR, EPIPE);
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;
- }
+ }
+
if (sentbytes == count) { /* success */
return count;
} else if (sentbytes > count) { /* too many bytes */
@@ -1736,6 +1731,12 @@ 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;
}
}
}