Skip to content

send(), recv() and WSABUF expect null-terminated strings instead of buffers #71

Description

@odorovskoy

Several Windows Sockets functions/structures unnecessary require null-terminated buffers (as if it were C strings). These are related to sending/receiving data via network and can work with any buffers, not just null-terminated.

  1. send() / sendto(): C type of buf parameter const char * gets translated to ?[*:0]const u8, but it does not represent a C-string, should be just ?[*]const u8.
    https://github.com/marlersoft/zigwin32/blob/714694dc2e2551ff1dae9ac052b9e88fb7fbabba/win32/networking/win_sock.zig#L5835-L5841
    https://github.com/marlersoft/zigwin32/blob/714694dc2e2551ff1dae9ac052b9e88fb7fbabba/win32/networking/win_sock.zig#L5844-L5853

  2. recv() / recvfrom(): C type of buf parameter char * gets translated to ?PSTR (which means ?[*:0]u8) instead of just ?[*]u8.
    https://github.com/marlersoft/zigwin32/blob/714694dc2e2551ff1dae9ac052b9e88fb7fbabba/win32/networking/win_sock.zig#L5663-L5669
    https://github.com/marlersoft/zigwin32/blob/714694dc2e2551ff1dae9ac052b9e88fb7fbabba/win32/networking/win_sock.zig#L5672-L5681

  3. buf field of WSABUF structure is a pointer to a buffer which does not have to be null-terminated. Current definition is again ?PSTR instead of ?[*]u8:
    https://github.com/marlersoft/zigwin32/blob/714694dc2e2551ff1dae9ac052b9e88fb7fbabba/win32/networking/win_sock.zig#L4854-L4857

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions