Skip to content

A possible divide by zero bug in p12_key.c #16331

@yiyuaner

Description

@yiyuaner

In the file p12_key.c, the function PKCS12_key_gen_uni has the following code:

u = EVP_MD_size(md_type);
if (u < 0 || v <= 0)
    goto err;
...
for (j = 0; j < v; j++)
    B[j] = Ai[j % u];

The variable u is used as a divisor. Since the code explicitly checks whether u is negative, I think it should also avoid the case when u=0 to prevent divide by zero bugs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    branch: 1.1.1Applies to OpenSSL_1_1_1-stable branch (EOL)branch: masterApplies to master branchtriaged: bugThe issue/pr is/fixes a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions