-
Notifications
You must be signed in to change notification settings - Fork 310
HPCC-35234 Ensure XRef handles trailing extensions correctly #21051
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
base: candidate-10.0.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -305,7 +305,8 @@ RemoteFilename &constructPartFilename(IGroup *grp,unsigned partNo,unsigned copy, | |||||||||
| { | ||||||||||
| partNo--; | ||||||||||
| StringBuffer partName; | ||||||||||
| if (!lname||!*lname) | ||||||||||
| const char *tailExt = nullptr; | ||||||||||
| if (isEmptyString(lname)) | ||||||||||
| { | ||||||||||
| if (!pmask) | ||||||||||
| { | ||||||||||
|
|
@@ -314,13 +315,23 @@ RemoteFilename &constructPartFilename(IGroup *grp,unsigned partNo,unsigned copy, | |||||||||
| } | ||||||||||
| lname = expandMask(partName, pmask, partNo, max); | ||||||||||
| } | ||||||||||
| else if (!isEmptyString(pmask)) | ||||||||||
| { | ||||||||||
| // pmask may contain trailing extensions that aren't in lname | ||||||||||
| const char *ext = strchr(pmask, '.'); | ||||||||||
| assertex(ext); // pmask should have at least one extension for the part mask | ||||||||||
| tailExt = strchr(ext+1, '.'); | ||||||||||
|
Comment on lines
+322
to
+323
|
||||||||||
| assertex(ext); // pmask should have at least one extension for the part mask | |
| tailExt = strchr(ext+1, '.'); | |
| if (ext) | |
| tailExt = strchr(ext+1, '.'); |
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.
It may not be the best to error on this, but it should always be the case that the pmask have at least one extension. Otherwise it would not have been able to deduce the part mask and this file would not make it here. It would be treated as an external file.
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.
strchr(pmask, '.')searches the entire string, so ifpmaskincludes a directory path containing dots (e.g./var/lib/hpcc/v1.2/data/file._$P$),extwill point into the directory portion, andtailExtmay become incorrect (or misleadingly non-null). This can result in appending the wrong substring tofullname, producing malformed filenames. Consider finding dots only in the basename portion ofpmask(after the last path separator), or use an existing path/filename utility in the codebase to locate extensions reliably.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.
pmask comes from cFileDesc::getNameMask and will only ever contain the file name.