Skip to content

Fix functions that rely on nonportable malloc behaviour #29

@kirill-shevtsov

Description

@kirill-shevtsov

From man malloc:

Nonportable behavior
The behavior of these functions when the requested size is zero is glibc specific; other implementations may return NULL without setting errno, and portable POSIX programs should tolerate such behavior.

Two unit tests with empty plain text will fail on systems where malloc(0) returns NULL, e.g., AIX:

check_jwe.c:172:F:core:test_cjose_jwe_self_encrypt_self_decrypt_empty:0: cjose_jwe_encrypt [RSA-OAEP/A128GCM] failed: out of memory, file: src/jwe.c, function: _cjose_jwe_malloc, line: 198
check_jws.c:113:F:core:test_cjose_jws_self_sign_self_verify_empty:0: cjose_jws_sign [PS256] failed: out of memory, file: src/jws.c, function: _cjose_jws_build_dat, line: 145

Also test_cjose_jwe_self_encrypt_self_decrypt_many will fail for RSA-OAEP + A128GCM if the first random byte it generates is zero.

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