[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#315235: kernel: sending with MSG_MORE causes data-loss.



Package: kernel
Severity: minor


When sending data to an IPv4 tcp socket with the MSG_MORE flag
and there are data to be read from the socket, the sent data
is lost when the socket is closed.

How to test:

Compile this program and run it with a free tcp port as argument:
----------------------8<-----------------------
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <netdb.h>
#include <string.h>

int
main(int argc, char **argv)
{
    struct sockaddr_in socket_addr;
    int fd = socket(PF_INET, SOCK_STREAM, 0);
    socklen_t len = sizeof(socket_addr);
    int on = 1;

    setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof(on));
    memset(&socket_addr, 0, sizeof(socket_addr));
    socket_addr.sin_family = AF_INET;
    socket_addr.sin_port = htons(atoi(argv[1]));
    socket_addr.sin_addr.s_addr = INADDR_ANY;
    bind(fd, (struct sockaddr *) &socket_addr, sizeof(socket_addr));
    listen(fd, 1);
    fd = accept(fd, (struct sockaddr *) &socket_addr, &len);
    recv(fd, &on, 1, 0);
    send(fd, "HI ", 3, 0);
    send(fd, "THERE\r\n", 8, MSG_MORE);
    close(fd);
    sleep(5);
    return 0;
}
----------------------8<-----------------------

Connect to the port with telnet or netcat and send at least 2 bytes to it.

The client will be able to read "HI ", but the "THERE\r\n" part is lost.

I've also tested this on someone's localy compiled 2.4.26-k7-smp kernel
with the same result.


-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.4.25-1-686-smp
Locale: LANG=sv_SE, LC_CTYPE=sv_SE (charmap=ISO-8859-1)



Reply to: