Commit 17444c9c84fd0c8679499198fd4ee3b155fb297f

Authored by bellard
1 parent bf1b938f

fixed invalid received length


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1155 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 6 additions and 2 deletions
slirp/socket.c
@@ -175,8 +175,12 @@ soread(so) @@ -175,8 +175,12 @@ soread(so)
175 * a close will be detected on next iteration. 175 * a close will be detected on next iteration.
176 * A return of -1 wont (shouldn't) happen, since it didn't happen above 176 * A return of -1 wont (shouldn't) happen, since it didn't happen above
177 */ 177 */
178 - if (n == 2 && nn == iov[0].iov_len)  
179 - nn += recv(so->s, iov[1].iov_base, iov[1].iov_len,0); 178 + if (n == 2 && nn == iov[0].iov_len) {
  179 + int ret;
  180 + ret = recv(so->s, iov[1].iov_base, iov[1].iov_len,0);
  181 + if (ret > 0)
  182 + nn += ret;
  183 + }
180 184
181 DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn)); 185 DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
182 #endif 186 #endif