Skip to content

Commit

Permalink
Fix #86, Check return from chmod
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Nov 12, 2022
1 parent 46b29f8 commit 935a55d
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 @@ -1436,6 +1436,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 @@ -1451,7 +1452,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 935a55d

Please sign in to comment.