-
Notifications
You must be signed in to change notification settings - Fork 4.4k
[8.6.0] Force rctx.{download_and,}extract to create user-readable files (ht…
#28551
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
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 |
|---|---|---|
|
|
@@ -137,7 +137,9 @@ public Path decompress(DecompressorDescriptor descriptor) | |
| try (OutputStream out = filePath.getOutputStream()) { | ||
| ByteStreams.copy(tarStream, out); | ||
| } | ||
| filePath.chmod(entry.getMode()); | ||
| // Ensure that all files are at least user-readable. Some archives contain files that | ||
| // are not, but many other tools are working around this and thus mask these issues. | ||
| filePath.chmod(entry.getMode() | 0400); | ||
|
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. Using the magic number |
||
|
|
||
| // This can only be done on real files, not links, or it will skip the reader to | ||
| // the next "real" file to try to find the mod time info. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,7 +168,9 @@ private static void extractZipEntry( | |
| throw new InterruptedException(); | ||
| } | ||
| } | ||
| outputPath.chmod(permissions); | ||
| // Ensure that all files are at least user-readable. Some archives contain files that | ||
| // are not, but many other tools are working around this and thus mask these issues. | ||
| outputPath.chmod(permissions | 0400); | ||
|
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. |
||
| outputPath.setLastModifiedTime(entry.getTime()); | ||
| } | ||
| } | ||
|
|
||
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.
Using the magic number
0400for file permissions can make the code harder to understand and maintain. It's better to define a named constant to represent this value, for example:private static final int USER_READ_PERMISSION = 0400;. This makes the intent of the code clearer and reduces the risk of typos when dealing with security-sensitive permission bits.