fix(cpp): Handle npos in PathToDirectory for S3 URIs without query strings#888
fix(cpp): Handle npos in PathToDirectory for S3 URIs without query strings#888shivendra-dev54 wants to merge 7 commits intoapache:mainfrom
Conversation
|
@Sober7135 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #888 +/- ##
============================================
+ Coverage 76.83% 80.67% +3.84%
Complexity 615 615
============================================
Files 84 94 +10
Lines 8897 10707 +1810
Branches 1055 1055
============================================
+ Hits 6836 8638 +1802
- Misses 1821 1829 +8
Partials 240 240
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This is not quite accurate, since no test case was added for this bug. Testing this bug is also somewhat complicated, because More importantly, this bug is only exercised through incubator-graphar/cpp/src/graphar/graph_info.cc Lines 1405 to 1416 in d535a43 I can think of two possible solutions:
Actually, I am not familiar with this kind of problem. Any advice? CC @yangxk1 |
Signed-off-by: devadhe sb <devadheshivendra54@gmail.com>
|
@Sober7135 here is what I did
But I have added that function to |
Reason for this PR
Fixes #881
PathToDirectorywas crashing with astd::out_of_rangeexception when parsing valid S3 URIs that do not contain a query string (?). This happens becausefind_last_of('?')returnsstd::string::npos, which was being passed directly intopath.substr().What changes are included in this PR?
Added an explicit check for
std::string::nposinPathToDirectory. When an S3 URI without a query string is processed, it now correctly identifies the entire path as the prefix and sets the suffix to an empty string, safely avoiding the out-of-bounds crash.Are these changes tested?
Yes, the C++ test suite was compiled and run locally, and all tests pass successfully.
Are there any user-facing changes?
No.
Critical Fix: Fixes a bug that causes a crash (
std::out_of_rangeexception) when parsing valid S3 URIs without query strings.