Skip to content

Commit

Permalink
vcard_test.c - ensure a filename option is provided beforehand.
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Winter committed Apr 22, 2024
1 parent 544ed7d commit ef0a0d8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/test/libicalvcard/vcard_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,23 @@ void strip_errors(vcardcomponent *comp)

int main(int argc, const char **argv)
{
const char *fname = argv[1];
int fd;
const char *fname;
struct stat sbuf;
size_t filesize;
int fd = open(fname, O_RDONLY);
void *data = NULL;

if (argc != 2) {
fprintf(stderr, "Usage: %s fname\n", argv[0]);
exit(1);
}

fname = argv[1];
fd = open(fname, O_RDONLY);
if (fd < 0) {
fprintf(stderr, "Error: unable to open %s\n", fname);
exit(1);
}
fstat(fd, &sbuf);
filesize = sbuf.st_size; //to make fortify compile happy
data = malloc(filesize+1);
Expand Down

0 comments on commit ef0a0d8

Please sign in to comment.