Skip to content

Potential endian problems? #1

Description

@spacewander

IMHO, function is_big_endian and l2b could be replaced with htonl and its family.

And it seems that this project doesn't check the endian in some places. For example,

https://github.com/ipipdotnet/ipdb-c/blob/master/ipdb.c#L63

return l2b((unsigned int) tar);

Should we check the endian before calling l2c? Maybe better to use htonl?

https://github.com/ipipdotnet/ipdb-c/blob/master/ipdb.c#L146

int size = (reader->data[resolved] << 8) | reader->data[resolved + 2];

Is this line incorrect under big endian? I guess it could be replaced with htons. BTW, it should be resolved + 1, not resolved + 2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions