Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CID generation is wrong #302

Open
RichardTea opened this issue Jun 8, 2023 · 0 comments
Open

CID generation is wrong #302

RichardTea opened this issue Jun 8, 2023 · 0 comments
Labels
bug fixed in development branch Fixed in a development branch for the version milestone
Milestone

Comments

@RichardTea
Copy link
Contributor

RichardTea commented Jun 8, 2023

CIDs are being generated by the following code:

CID CID::CreateCid()
{
    QUuid uuid = QUuid::createUuid();
    QByteArray bits = uuid.toByteArray();

    CID result;
    memcpy(result.m_cid, bits.data(), CIDBYTES);
    return result;
}

This is simply incorrect. QUuid::toByteArray() returns a string representation of the UUID, eg:
{d6baa5c0-c5e9-48eb-bba3-f64a86f29ef8}
Fortunately the string representation is always larger than the 16 bytes, and is fairly unique.

The correct call is QUuid::toRfc4122() to get the big-endian representation.

@marcusbirkin marcusbirkin added this to the v2.2 milestone Jun 9, 2023
@marcusbirkin marcusbirkin added the fixed in development branch Fixed in a development branch for the version milestone label Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fixed in development branch Fixed in a development branch for the version milestone
Projects
None yet
Development

No branches or pull requests

2 participants