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

Fix 'Assertion failed' in softhsm2-dump-file when encountering a zero-length element #761

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions src/bin/dump/softhsm2-dump-file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,15 @@ void dump(FILE* stream)
}
printf("(length %lu)\n", (unsigned long) len);

std::vector<uint8_t> value((size_t) len);
if (!readBytes(stream, value))
{
corrupt(stream);
return;
if (len > 0) {
dogo42 marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (len > 0) {
if (len > 0)
{

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if the Github GUI lost this change.

std::vector<uint8_t> value((size_t) len);
if (!readBytes(stream, value))
{
corrupt(stream);
return;
}
dumpBytes(value);
}
dumpBytes(value);
}
else if (disktype == ATTRMAP_ATTR)
{
Expand All @@ -461,13 +463,15 @@ void dump(FILE* stream)
}
printf("(length %lu)\n", (unsigned long) len);

std::vector<Attribute> value;
if (!readMap(stream, len, value))
{
corrupt(stream);
return;
}
dumpMap(value);
if (len > 0) {
dogo42 marked this conversation as resolved.
Show resolved Hide resolved
std::vector<Attribute> value;
if (!readMap(stream, len, value))
{
corrupt(stream);
return;
}
dumpMap(value);
}
}
else if (disktype == MECHSET_ATTR)
{
Expand Down