TF1/TString possible overflow fix + Warning in TString#8426
TF1/TString possible overflow fix + Warning in TString#8426Axel-Naumann merged 2 commits intoroot-project:masterfrom
Conversation
|
Can one of the admins verify this patch? |
1b529b2 to
b3aa3b1
Compare
|
I somehow managed to mess up the commits in multiple of my PR's. Sorry for the inconvenience. |
hist/hist/src/TF1.cxx
Outdated
| const auto formulaLength = strlen(formula); | ||
| // First check if we are making a convolution | ||
| if (TString(formula, 5) == "CONV(" && formula[strlen(formula) - 1] == ')') { | ||
| if (TString(formula, 5) == "CONV(" && formula[formulaLength - 1] == ')') { |
There was a problem hiding this comment.
Here you also need the strncmp trick, because that's the line that triggered the error that started all this.
There was a problem hiding this comment.
Look up "git interactive rebase". You can use it to fix the existing commits (git commit --fixup xxxx), and you can also remove the "Added some constants" "Revert Added some constants" while rebasing.
Once you get the hang of it, you will love it!
There was a problem hiding this comment.
Ah yes, I forgot that. I will change it as soon as I'm home
There was a problem hiding this comment.
Ahh thanks for the interactive rebase tip. I was looking for something like that 😀
|
Ah, there we go. |
There was a problem hiding this comment.
Now that you know how to rebase, could you edit the commit messages, please?
(git rebase -i origin/master) and then use e to edit the messages.
- Use a short title, max 80 characters, e.g. "Add warning in TString constructor"
- Then, after an empty line, explain in detail what you did and why. E.g. "Warn when a TString of a fixed length is constructed from an input string that's too short."
Like this, it will be easy to understand what happened when people are looking into these commits at some point in the future.
For the TF1 fix, explain what the bug was. Edit: And mention something like Fix #8136 in the commit message.
Okay. I will change it |
51ee9a6 to
6cd4ca7
Compare
|
Are these commit names better? |
A bit, but look at this commit for example: You can use the message to explain a bit better what was going on e.g.: |
So in the interactive rebase I just write this detailed description under the commit? Because when I do that it tells me that that line is invalid. Do I need to use some special indentation? |
Ah, no! That's r for "reword". |
The user now gets a warning in the TString::TString constructor if the input string is shorter than the requested size.
|
I think I got it. Thank you @hageboeck for all of the help :D |
|
Very nice! Interactive rebase is awesome once you learn how to use it! 👏 |
|
@phsft-bot build |
|
Starting build on |
Yeah, it is. Feels like I've been living under a rock hehe |
|
Build failed on ROOT-performance-centos8-multicore/default. Warnings:
|
|
Build failed on ROOT-ubuntu16/nortcxxmod. Warnings:
|
|
Are these warnings critical? Is there something I can do? |
|
Yes they need to be fixed. I could tell you - but what I'd recommend (look, we're teaching you here :-) ) is to copy the warning text, search the Internet, and pick the most helpful posting on StackOverflow: that'll explain you what to do. And it's a key pattern to become a successful developer, it's how all of us fix our warnings 🤣 |
Ahh hehe. Okay, I'll try to fix it :D . Thanks for the learning opportunity |
|
Build failed on mac11.0/cxx17. Warnings:
|
|
Build failed on mac1014/python3. Warnings:
|
|
That should take care of that |
|
Build failed on ROOT-debian10-i386/cxx14. Errors:
Warnings:
|
|
@phsft-bot build |
|
Starting build on |
Axel-Naumann
left a comment
There was a problem hiding this comment.
Please correct the whitespace issue. LGTM otherwise!
|
Can you squash all commits but "Added Warning to TString constuctor" into one, such that this branch ends up having two commits? You can do that with interactive rebase, making all commits after the second (!) as "fixup", such that they just modify / update the second commit. |
3750978 to
435f546
Compare
The length of formula is now chached and reused. Furthermore strncmp is used instead of TString for preformance reasons.
|
That should be all there is to format. At least according to clang-format |
|
@phsft-bot build |
|
Starting build on |
|
Looks good to me, let's wait for the build! |
|
I think the builds were successful |
Yes, they were. Yesterday, when you wrote this message, Jenkins (the most important step) was still running. |
|
@Axel-Naumann please merge. |
I have tried to fix this issue.
This should prevent a possible overflow in TF1, as now the min of the length of strlen(formula) and 5 is taken, therefore preventing a possible overflow.
Also in TString if the first n characters of cs conatin \0 it warns you.