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

debugger: Safer GDB/MI parsing and other fixes #202

Merged
merged 20 commits into from
Nov 15, 2015

Conversation

b4n
Copy link
Member

@b4n b4n commented Mar 16, 2015

This Introduces a proper GDB/MI parser to replace the dangerous string manipulations. This part of the patchset is large and might have introduced issues I overlooked. It probably requires extensive testing.
Note that I only replaced the GDB/MI parsing code with something more generic and robust, the logic is (should be) still the same.

The rest of the changes are more trivial and should be straightforward.

If needed or requested, I can split the changes and/or squash some of the commits together. I did not do it because I'm not certain it's needed, and I prefer to do it last in case this PR leads to additional changes.

Beware that I'm not a real user of the debugger plugin, so I only performed limited testing -- I tried to use the most features I could find, both before and after my changes, but didn't use the plugin in any kind of daily basis.

b4n added 20 commits October 24, 2014 14:18
strcpy() requires that the source and destination strings do not
overlap, so fix the code to avoid this.
This fixes a leak, a possible NULL-pointer dereference and buffer
overflows.
Including:
* Fix parsing hex escapes;
* Allow short forms for hex and octal escapes;
* Remove some dead code;
* Disable debugging prints;
* Only recognize ASCII for special meanings.
Apparently GCC is not smart enough to understand that when the a NULL
name is passed to `gdb_mi_result_foreach_matched` the `strcmp()` call
cannot possibly happen.  Work around the warnings it emits by adding an
explicit (and useless) check on the `strcmp()` argument, which probably
will be optimized out anyway.
This is likely to *NOT* be completely compatible with what the original
code did.  There are some explicitly different things that may either
have been errors in the old code or changes in GDB output.

The changes seem (basic testing) to work fine on Debian's GDB 7.7.1.

NOTE: There is currently no conversion from the locale encoding to
UTF-8.  The GDB/MI module decodes the 7bit strings from GDB, but they
probably encode locale-encoded data.  This means this probably won't
work reliably on non-UTF-8 locales without an appropriate conversion.
"Appropriate conversion" yet has to be defined -- but as UTF-8 covers
all of Unicode it probably is OK to convert back and forth even when
not strictly required, it should at worse be useless.
Actually this reason isn't handled, and if it worked earlier is just
that it would use the previous stop reason in this case.

The updated code broke that as it always set the reason even when not
handled, so restore the old version.
Use `g_snprintf()` instead of the unsafe `sprintf()`.
Fix the code for prompt to be locale-agnostic and actually work.
This doesn't change anything however, because the default action for
unknown record type is reporting a prompt, and a real prompt would
trigger it.
@frlan
Copy link
Member

frlan commented Nov 13, 2015

I will postpone this again. Now to 1.27 due to lag of review.

@frlan frlan modified the milestones: 1.27, 1.26 Nov 13, 2015
@b4n
Copy link
Member Author

b4n commented Nov 14, 2015

@frlan yeah, thanks. Though, in practice I'll probably just merge is as-is after 1.26, as the previous maintainer dropped and was alright with it, and I got positive response from a few people having tested it in the context of other reports.

This said, if anyone wishes to take maintenance of this plugin and/or review this and/or test this is more than welcome. I'm not planning to maintain it for real in the long term.

@frlan
Copy link
Member

frlan commented Nov 14, 2015

I'm fine with it. With having Devyn looking into complete debugging stack I've got a good feeling its not ending in a huge mess.

frlan added a commit that referenced this pull request Nov 15, 2015
debugger: Safer GDB/MI parsing and other fixes
@frlan frlan merged commit 835bea0 into geany:master Nov 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants