Skip to content

Bug: Bad offset when sending or receiving multiple times in src/tcp.c lines 208 and 255 #58

Description

@bretondu42-bot

Hello,

I spotted what appears to be a bug in src/tcp.c, lines 208 (send) and 255 (receive).

In the transmission and reception loops:

// tcp_send (), ligne 208
do {
    n = send(tcp_data->server_socket, message + n, length, 0); // <--
    ...
    length -= n;
    bytes_sent += n;
} while (length > 0);

// tcp_receive_(), ligne 255
do {
    n = recv(tcp_data->server_socket, message + n, length, flags); // <--
    ...
    length -= n;
    bytes_received += n;
} while (n > 0);

In both cases, the buffer offset should be cumulative:

  • For sending: message + bytes_sent (and not message + n)
  • For reception: message + bytes_received (and not message + n)

Otherwise, there is a risk of rewriting/rereading in the wrong place, or even corrupting the buffer or looping over the same data.

Please confirm and correct if necessary.

Sincerely,


Signalement automatisé via Copilot Issue Agent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions