summaryrefslogtreecommitdiff
path: root/src/filebuf.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-11-03 17:02:07 -0500
committerEdward Thomson <ethomson@microsoft.com>2015-11-03 17:16:51 -0500
commitec50b23acc5a9f00f597fa877ad09cad56cb1204 (patch)
treed219f21a18d62dabd4e4487c1a2b3e313da6d30b /src/filebuf.c
parent2d556f31665e9fde0310f4ae89cd3f01a5810b1c (diff)
downloadlibgit2-ec50b23acc5a9f00f597fa877ad09cad56cb1204.tar.gz
filebuf: detect directories in our way
When creating a filebuf, detect a directory that exists in our target file location. This prevents a failure later, when we try to move the lock file to the destination.
Diffstat (limited to 'src/filebuf.c')
-rw-r--r--src/filebuf.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/filebuf.c b/src/filebuf.c
index 2bbc210ba..17efe872e 100644
--- a/src/filebuf.c
+++ b/src/filebuf.c
@@ -357,6 +357,12 @@ int git_filebuf_open(git_filebuf *file, const char *path, int flags, mode_t mode
memcpy(file->path_lock, file->path_original, path_len);
memcpy(file->path_lock + path_len, GIT_FILELOCK_EXTENSION, GIT_FILELOCK_EXTLENGTH);
+ if (git_path_isdir(file->path_original)) {
+ giterr_set(GITERR_FILESYSTEM, "path '%s' is a directory", file->path_original);
+ error = GIT_EDIRECTORY;
+ goto cleanup;
+ }
+
/* open the file for locking */
if ((error = lock_file(file, flags, mode)) < 0)
goto cleanup;