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

ElfCoreDump is not respecting 4-byte padding between Note entries #48

Open
dedmen opened this issue Nov 8, 2021 · 0 comments
Open

ElfCoreDump is not respecting 4-byte padding between Note entries #48

dedmen opened this issue Nov 8, 2021 · 0 comments

Comments

@dedmen
Copy link

dedmen commented Nov 8, 2021

https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-18048.html

Padding is present, if necessary, to ensure 4-byte alignment for the descriptor. Such padding is not included in namesz.

Thats done correctly here with NameSize:

int nameEnd = reader.Position + (int)note.NameSize;

But the 4-byte padding to the next note is not considered.

The first descsz bytes in desc hold the note descriptor. If no descriptor is present, descsz contains the value zero. Padding is present, if necessary, to ensure 4-byte alignment for the next note entry. Such padding is not included in descsz.

descsz also needs to be 4 byte padded same as name.

Ghetto fix

string name = reader.ReadString();
reader.Position = nameEnd;
byte[] content = reader.ReadBlock(note.n_descsz);

                            string name = reader.ReadString();
                            reader.Position = nameEnd;
                            int descEnd = reader.Position + (int)note.DescSizeWithPadding;
                            byte[] content = reader.ReadBlock(note.n_descsz);
                            reader.Position = descEnd;

Will make a pull request someday when I get the time for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant