Skip to content

Commit

Permalink
HotFix nasa#1300, do not set file permissions on UT assert outputs
Browse files Browse the repository at this point in the history
File permissions in general are a POSIX concept, but this tool should be
pure C99.  It should not rely on any POSIX headers or POSIX-specific
API calls.
  • Loading branch information
jphickey committed Oct 4, 2022
1 parent 14be8d5 commit 42a1eed
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions ut_assert/src/uttools.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <sys/stat.h>

#include "common_types.h"
#include "utassert.h"
Expand All @@ -54,18 +53,10 @@ typedef struct

bool UtMem2BinFile(const void *Memory, const char *Filename, uint32 Length)
{
FILE * fp;
int fd;
struct stat dststat;
FILE *fp;

if ((fp = fopen(Filename, "w")))
{
fd = fileno(fp);
if (fstat(fd, &dststat) == 0)
{
fchmod(fd, dststat.st_mode & ~(S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH));
}

fwrite(Memory, Length, 1, fp);
fclose(fp);
return true;
Expand Down Expand Up @@ -102,20 +93,12 @@ bool UtBinFile2Mem(void *Memory, const char *Filename, uint32 Length)

bool UtMem2HexFile(const void *Memory, const char *Filename, uint32 Length)
{
FILE * fp;
uint32 i;
uint32 j;
int fd;
struct stat dststat;
FILE * fp;
uint32 i;
uint32 j;

if ((fp = fopen(Filename, "w")))
{
fd = fileno(fp);
if (fstat(fd, &dststat) == 0)
{
fchmod(fd, dststat.st_mode & ~(S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH));
}

for (i = 0; i < Length; i += 16)
{
fprintf(fp, " %06lX: ", (unsigned long)i);
Expand Down

0 comments on commit 42a1eed

Please sign in to comment.