Skip to content

Commit

Permalink
Merge pull request #124 from thnkslprpt:fix-86-check-chmod-return
Browse files Browse the repository at this point in the history
Fix #86, Check return from chmod
  • Loading branch information
dzbaker committed Jul 2, 2024
2 parents a707f25 + 935a55d commit 2c10360
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion elf2cfetbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,7 @@ int32 OpenSrcFile(void)
int32 OpenDstFile(void)
{
struct stat dststat;
int32 Status = SUCCESS;

/* Check to see if output file can be opened and written */
DstFileDesc = fopen(DstFilename, "w");
Expand All @@ -1448,7 +1449,15 @@ int32 OpenDstFile(void)
{
if (Verbose)
printf("%s: Destination file permissions after open = 0x%X\n", DstFilename, dststat.st_mode);
chmod(DstFilename, dststat.st_mode & ~(S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH));

Status = chmod(DstFilename, dststat.st_mode & ~(S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH));

if (Status != 0)
{
printf("%s: Error while attempting to modify file permissions\n", DstFilename);
return FAILED;
}

stat(DstFilename, &dststat);
if (Verbose)
printf("%s: Destination file permissions after chmod = 0x%X\n", DstFilename, dststat.st_mode);
Expand Down

0 comments on commit 2c10360

Please sign in to comment.