commit - 22eb897338c1f91ec8dfa725dd84ab38ed2b1aeb
commit + deeca23839609f94e076f97f16d1d7cde09daf3b
blob - 630a646167f300de74854bdd0b0098adaa34938e
blob + c13711cf098cbc488fdb86c373f4b4d4461cb3f5
--- lib/repository.c
+++ lib/repository.c
*/
#include <sys/queue.h>
+#include <sys/stat.h>
#include <limits.h>
#include <stdlib.h>
char *path_objects = got_repo_get_path_objects(repo);
char *path_refs = got_repo_get_path_refs(repo);
char *path_head = get_path_head(repo);
- int ret;
+ int ret = 0;
+ struct stat sb;
- ret = (path_git != NULL) && (path_objects != NULL) &&
- (path_refs != NULL) && (path_head != NULL);
+ if (lstat(path_git, &sb) == -1)
+ goto done;
+ if (!S_ISDIR(sb.st_mode))
+ goto done;
+ if (lstat(path_objects, &sb) == -1)
+ goto done;
+ if (!S_ISDIR(sb.st_mode))
+ goto done;
+
+ if (lstat(path_refs, &sb) == -1)
+ goto done;
+ if (!S_ISDIR(sb.st_mode))
+ goto done;
+
+ if (lstat(path_head, &sb) == -1)
+ goto done;
+ if (!S_ISREG(sb.st_mode))
+ goto done;
+ ret = 1;
+done:
free(path_git);
free(path_objects);
free(path_refs);