Fix userland ELF loader for zero sized BSS.
[qemu] / slirp / if.c
index 282b674..94132ca 100644 (file)
@@ -52,8 +52,8 @@ if_init()
        if_maxlinkhdr = 40;
 #endif
 #else
-        /* 14 for ethernet + 40 */
-        if_maxlinkhdr = 14 + 40;
+        /* 2 for alignment, 14 for ethernet, 40 for TCP/IP */
+        if_maxlinkhdr = 2 + 14 + 40;
 #endif
        if_mtu = 1500;
        if_mru = 1500;
@@ -79,14 +79,14 @@ writen(fd, bptr, n)
        int total;
        
        /* This should succeed most of the time */
-       ret = write(fd, bptr, n);
+       ret = send(fd, bptr, n,0);
        if (ret == n || ret <= 0)
           return ret;
        
        /* Didn't write everything, go into the loop */
        total = ret;
        while (n > total) {
-               ret = write(fd, bptr+total, n-total);
+               ret = send(fd, bptr+total, n-total,0);
                if (ret <= 0)
                   return ret;
                total += ret;
@@ -111,7 +111,7 @@ if_input(ttyp)
        DEBUG_CALL("if_input");
        DEBUG_ARG("ttyp = %lx", (long)ttyp);
        
-       if_n = read(ttyp->fd, (char *)if_inbuff, INBUFF_SIZE);
+       if_n = recv(ttyp->fd, (char *)if_inbuff, INBUFF_SIZE,0);
        
        DEBUG_MISC((dfd, " read %d bytes\n", if_n));
        
@@ -315,6 +315,8 @@ if_start(void)
        /* Encapsulate the packet for sending */
         if_encap(ifm->m_data, ifm->m_len);
 
+        m_free(ifm);
+
        if (if_queued)
           goto again;
 }