-
Notifications
You must be signed in to change notification settings - Fork 304
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
DAOS-15069 dfs: use memcpy instead of snprintf for readdir #13654
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 |
---|---|---|
|
@@ -568,7 +568,7 @@ fetch_entry(dfs_layout_ver_t ver, daos_handle_t oh, daos_handle_t th, const char | |
|
||
/** TODO - not supported yet */ | ||
if (strcmp(name, ".") == 0) | ||
D_ASSERT(0); | ||
return ENOTSUP; | ||
|
||
if (xnr) { | ||
D_ALLOC_ARRAY(pxnames, xnr); | ||
|
@@ -3790,11 +3790,8 @@ readdir_int(dfs_t *dfs, dfs_obj_t *obj, daos_anchor_t *anchor, uint32_t *nr, | |
D_GOTO(out, rc = daos_der2errno(rc)); | ||
|
||
for (ptr = enum_buf, i = 0; i < number; i++) { | ||
int len; | ||
|
||
len = snprintf(dirs[key_nr].d_name, | ||
kds[i].kd_key_len + 1, "%s", ptr); | ||
D_ASSERT(len >= kds[i].kd_key_len); | ||
memcpy(dirs[key_nr].d_name, ptr, kds[i].kd_key_len); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe check that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If that condition would be false, then we have landed some data corruption in the container and this would be the least of the problems :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But if we don't detect it here, we'll have two data corruptions. :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my point was we probably won't even get here if there is data corruption in the container. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding in another PR sounds good to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively, if the check is 100% redundant, a comment that explains this would help (it's not obvious unless you know the server side, I guess). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there is an issue here but adding in another PR seems the way to go. |
||
dirs[key_nr].d_name[kds[i].kd_key_len] = '\0'; | ||
ptr += kds[i].kd_key_len; | ||
|
||
/** stat the entry if requested */ | ||
|
@@ -6542,8 +6539,6 @@ dfs_listxattr(dfs_t *dfs, dfs_obj_t *obj, char *list, daos_size_t *size) | |
continue; | ||
|
||
for (ptr = enum_buf, i = 0; i < number; i++) { | ||
int len; | ||
|
||
if (strncmp("x:", ptr, 2) != 0) { | ||
ptr += kds[i].kd_key_len; | ||
continue; | ||
|
@@ -6556,10 +6551,8 @@ dfs_listxattr(dfs_t *dfs, dfs_obj_t *obj, char *list, daos_size_t *size) | |
if (list_size < kds[i].kd_key_len - 2) | ||
continue; | ||
|
||
len = snprintf(ptr_list, kds[i].kd_key_len - 1, "%s", | ||
ptr + 2); | ||
D_ASSERT(len >= kds[i].kd_key_len - 2); | ||
|
||
memcpy(ptr_list, ptr + 2, kds[i].kd_key_len - 2); | ||
ptr_list[kds[i].kd_key_len - 2] = '\0'; | ||
list_size -= kds[i].kd_key_len - 1; | ||
ptr_list += kds[i].kd_key_len - 1; | ||
ptr += kds[i].kd_key_len; | ||
|
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.
This is progress but wasn't there a different ticket with a reprodyucer for this? Without seeing that ticket could dfs_lookup_rel() skip over entiries named "." when doing the path walk, then the rerroducer should pass rather than exit gracefully as presumably it does with this fix.
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.
we can leave that case for the ticket. this is fine for now