In C89 it is undefined behavior to pass `NULL` pointers to `strncmp` and later on in C99 it has been explicitly stated that functions with an argument declared as `size_t nmemb` specifying the array length shall always have valid parameters, no matter if `nmemb` is 0 or not (see ISO 9899 §7.21.1.2). The function `str_equal_no_trailing_slash` always passes its parameters to `strncmp` if their lengths match. This means if one parameter is `NULL` and the other one either `NULL` or a string with length 0 we will pass the pointers to `strncmp` and cause undefined behavior. Fix this by explicitly handling the case when both lengths are 0.
| Name |
Last commit
|
Last update |
|---|---|---|
| cmake/Modules | Loading commit data... | |
| deps | Loading commit data... | |
| docs | Loading commit data... | |
| examples | Loading commit data... | |
| include | Loading commit data... | |
| script | Loading commit data... | |
| src | Loading commit data... | |
| tests | Loading commit data... | |
| .HEADER | Loading commit data... | |
| .editorconfig | Loading commit data... | |
| .gitattributes | Loading commit data... | |
| .gitignore | Loading commit data... | |
| .mailmap | Loading commit data... | |
| .travis.yml | Loading commit data... | |
| AUTHORS | Loading commit data... | |
| CHANGELOG.md | Loading commit data... | |
| CMakeLists.txt | Loading commit data... | |
| CODE_OF_CONDUCT.md | Loading commit data... | |
| CONTRIBUTING.md | Loading commit data... | |
| CONVENTIONS.md | Loading commit data... | |
| COPYING | Loading commit data... | |
| Makefile.embed | Loading commit data... | |
| PROJECTS.md | Loading commit data... | |
| README.md | Loading commit data... | |
| THREADING.md | Loading commit data... | |
| api.docurium | Loading commit data... | |
| appveyor.yml | Loading commit data... | |
| git.git-authors | Loading commit data... | |
| libgit2.pc.in | Loading commit data... | |
| libgit2_clar.supp | Loading commit data... |