Skip to content

Pass-by-value instead of pointer parameter in base64 to bin and hex to bin functions #83

@ionspin

Description

@ionspin

Similar to the issue #65 there are a couple of codec helper functions that are using java pass-by-value paramateres instead of pointers and therefore not correctly passing back the length information.
Base64 to bin libsodium C code:

int
sodium_base642bin(unsigned char * const bin, const size_t bin_maxlen,
                  const char * const b64, const size_t b64_len,
                  const char * const ignore, size_t * const bin_len,
                  const char ** const b64_end, const int variant)

Lazysodium java code:

    public native int sodium_base642bin(byte[] bin,
                                        int binMaxLen,
                                        byte[] b64,
                                        int b64Len,
                                        byte[] ignore,
                                        int binLen,
                                        byte b64End,
                                        int variant);

If I am not mistaken parameter binLen should be of type Pointer like it was handled in this commit

The same situation is repeated for hex2bin
Libsodium C code:

int
sodium_hex2bin(unsigned char *const bin, const size_t bin_maxlen,
               const char *const hex, const size_t hex_len,
               const char *const ignore, size_t *const bin_len,
               const char **const hex_end)

Lazysodium java code:

    public native int sodium_hex2bin(byte[] bin,
                                     int binMaxLen,
                                     byte[] hex,
                                     int hexLen,
                                     byte[] ignore,
                                     int binLen,
                                     byte hexEnd);

Same paramater name, binLen

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