Skip to content
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

chunked: fix unmarshaling of file names #1879

Merged

Conversation

giuseppe
Copy link
Member

@giuseppe giuseppe commented Apr 9, 2024

The getString() function was used to extract string values, but it doesn't handle escaped characters. Replace it with iter.ReadString() that is slower but handles escaped characters correctly.

Closes: #1878

Copy link
Contributor

openshift-ci bot commented Apr 9, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rhatdan
Copy link
Member

rhatdan commented Apr 9, 2024

LGTM
@nalind @mtrmac @saschagrunert @flouthoc PTAL

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Does xattrs need this as well?
  • If this does not use StringsBuf, the fields should not be counted in count
  • (I am ambivalent about the concept of StringsBuf, there is no documented rationale. Is it to save on per-object allocation cost?)
  • That ReadStringAsSlice does not process escapes is understandable but not immediately obvious to me. Consider turning getString([]byte) into a getStringWithoutEscapes(iter), to document that behavior in one place (and to save a bit on code size / repetitiveness).

The getString() function was used to extract string values, but it
doesn't handle escaped characters.  Replace it with iter.ReadString()
that is slower but handles escaped characters correctly.

Closes: containers#1878

Signed-off-by: Giuseppe Scrivano <[email protected]>
@giuseppe giuseppe force-pushed the fix-chunked-name-escaping branch from ab17050 to f388a77 Compare April 9, 2024 20:04
@giuseppe
Copy link
Member Author

giuseppe commented Apr 9, 2024

  • (I am ambivalent about the concept of StringsBuf, there is no documented rationale. Is it to save on per-object allocation cost?)

yeah it was done exactly for that reason, but now that we are not using for name is unclear if it is still worth having.

For now, I've simplified the implementation and dropped the StringsBuf performance hack, we can revisit later if needed

@mtrmac
Copy link
Collaborator

mtrmac commented Apr 9, 2024

(Just to be explicit, I’m completely fine with StringsBuf continuing to exist. I have no reason to prefer either way.)

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for correctness, the simplification is nice.

I have no idea what’s the performance impact, I trust your judgement on this.

@mtrmac
Copy link
Collaborator

mtrmac commented Apr 9, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Apr 9, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit a3d902f into containers:main Apr 9, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid filename-escaping (?)
3 participants