projects
/
openwrt
/
staging
/
dedeckeh.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
scripts: mkhash fail on hashing a folder
[openwrt/staging/dedeckeh.git]
/
scripts
/
mkhash.c
diff --git
a/scripts/mkhash.c
b/scripts/mkhash.c
index ce156e979dea3761a1e2684cf046be8cf505abe8..ced4f3c34a8c3bf70f384c211eb6cc058140ccf3 100644
(file)
--- a/
scripts/mkhash.c
+++ b/
scripts/mkhash.c
@@
-85,6
+85,7
@@
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
+#include <sys/stat.h>
#define ARRAY_SIZE(_n) (sizeof(_n) / sizeof((_n)[0]))
#define ARRAY_SIZE(_n) (sizeof(_n) / sizeof((_n)[0]))
@@
-770,6
+771,13
@@
static int hash_file(struct hash_type *t, const char *filename, bool add_filenam
if (!filename || !strcmp(filename, "-")) {
str = t->func(stdin);
} else {
if (!filename || !strcmp(filename, "-")) {
str = t->func(stdin);
} else {
+ struct stat path_stat;
+ stat(filename, &path_stat);
+ if (S_ISDIR(path_stat.st_mode)) {
+ fprintf(stderr, "Failed to open '%s': Is a directory\n", filename);
+ return 1;
+ }
+
FILE *f = fopen(filename, "r");
if (!f) {
FILE *f = fopen(filename, "r");
if (!f) {