Skip to content

Commit 7525374

Browse files
committed
Open target files write-only and loosen their permissions
Because the target files are only written to, not read from, by either bsdiff or bspatch, we can open them write-only. Also, I don't see a reason for the file permissions to be 600, so loosen the permissions to be 644. Signed-off-by: Patrick McCarty <[email protected]>
1 parent 285133f commit 7525374

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/diff.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ int make_bsdiff_delta(char *old_filename, char *new_filename, char *delta_filena
586586
memset(&small_header, 0, sizeof(struct header_v21));
587587
memcpy(&small_header.magic, BSDIFF_HDR_FULLDL, 8);
588588

589-
efd = open(delta_filename, O_CREAT | O_EXCL | O_RDWR, 00600);
589+
efd = open(delta_filename, O_CREAT | O_EXCL | O_WRONLY, 00644);
590590
if (efd < 0) {
591591
close(fd);
592592
return -1;
@@ -668,7 +668,7 @@ int make_bsdiff_delta(char *old_filename, char *new_filename, char *delta_filena
668668
memset(&small_header, 0, sizeof(struct header_v21));
669669
memcpy(&small_header.magic, BSDIFF_HDR_FULLDL, 8);
670670

671-
efd = open(delta_filename, O_CREAT | O_EXCL | O_RDWR, 00600);
671+
efd = open(delta_filename, O_CREAT | O_EXCL | O_WRONLY, 00644);
672672
if (efd < 0) {
673673
close(fd);
674674
munmap(old_data, oldsize);
@@ -883,7 +883,7 @@ int make_bsdiff_delta(char *old_filename, char *new_filename, char *delta_filena
883883

884884
/* Create the patch file */
885885

886-
efd = open(delta_filename, O_CREAT | O_EXCL | O_RDWR, 00600);
886+
efd = open(delta_filename, O_CREAT | O_EXCL | O_WRONLY, 00644);
887887
if (efd < 0) {
888888
ret = -1;
889889
goto fulldl_free;

src/patch.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ static int apply_delta_v2(int subver, FILE *f,
690690
cfclose(&ef);
691691

692692
/* Write the new file */
693-
fd = open(new_filename, O_CREAT | O_EXCL | O_WRONLY, 0600);
693+
fd = open(new_filename, O_CREAT | O_EXCL | O_WRONLY, 00644);
694694
if (fd < 0) {
695695
ret = -1;
696696
goto writeerror;

0 commit comments

Comments
 (0)