Prove the absence of undefined behaviors
On the previous page, we found the root cause of the detected undefined behavior.
On the previous step, we realized that the code should not allocate a buffer of constant size but one of the same size as the input string. Fixing this should remove the undefined behavior.
To save you some time, we've prepared the code change in a dedicated branch called
You'll merge this branch to your master branch via a pull request. Here are the steps with a screen recording at the end:
1. On GitHub, click on New pull request on your fork project.
2. Change the compare branch to fix-memory-alloc.
3. Change the base repository to your fork project.
4. Review the changes in the diff. The
caesar_decryptfunctions take the length of the input string as an additional argument, and the code allocates a buffer
bufof the same size
str_lenas the input string.
5. Click on Create pull request, and again to confirm.
6. Click on Merge pull request, then Confirm merge.
You have just merged the code change to your master branch!
1. In TrustInSoft CI, click on
masterto go back to the Reference page:
2. If you did not change the Project settings, a new build should have been trigger on the new commit as described in the screenshot above. Otherwise you can still run a new build with the
Run new buildbutton in the top-right corner.
3. You can already see the analysis is now green, which mean no undefined behavior has been detected. By clicking on the
#2build, you can double check this fact: