-
Notifications
You must be signed in to change notification settings - Fork 767
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
Don't infinite loop when searching CLI history list #2560
Conversation
The easiest way to clean up the history list when moving an item is to just remove it and reinsert, so use pj_list_erase(). Fixes pjsip#2559
… & updates: trim string before compare (as history entries are trimmed), replace pj_list_insert_nodes_after() with pj_list_erase(), avoid buffer overflow in string copy, and a bit optimization: only copy string when needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the spec and implementation of pj_strtrim() doesn't give me assurance that it's safe for zero-length pj_str that has uninitialised ptr.
So perhaps move the strtrim() below the if?
The spec does not seem to specify anything about it, but looking at the implementation, the uninitalised ptr should never be dereferenced when the string is zero-length, so it should be safe? Or it is unsafe because of something else? OTOH the original code seems to assume that the string length is always greater than zero: It should be better if the string can be trimmed first so we get a 'clean' string when evaluating the length ( |
The code that's bothering me is: Ah right, you want to check the length after trimming. I initially thought there's no point in doing so and that's why I suggest to move it below. |
The easiest way to clean up the history list when moving an item is to
just remove it and reinsert, so use pj_list_erase().
Fixes #2559