Skip to content

Commit

Permalink
[XrdApps] First open then stat file to get consistent information
Browse files Browse the repository at this point in the history
  • Loading branch information
amadio committed Nov 26, 2024
1 parent 31a41eb commit 74bb634
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/XrdApps/Xrdadler32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,14 @@ int main(int argc, char *argv[])
}
if (argc == 1 || path[0] == '\0')
{ /* this is a local file */
if (argc > 1)
if (argc > 1)
{
strcpy(path, argv[1]);
rc = stat(path, &stbuf);
if (rc != 0 || ! S_ISREG(stbuf.st_mode) ||
(fd = open(path,O_RDONLY)) < 0)
if ((fd = open(path, O_RDONLY)) < 0 || fstat(fd, &stbuf) != 0 || !S_ISREG(stbuf.st_mode))
{
printf("Error_accessing %s\n", path);
if (fd != -1)
close(fd);
printf("Error opening %s: %s\n", path, strerror(errno));
return 1;
}
else /* see if the adler32 is saved in attribute already */
Expand Down

0 comments on commit 74bb634

Please sign in to comment.