mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-06 09:41:04 +00:00
Merge pull request #681 from scottjg/solaris-fixes
Fix build/runtime issues on Solaris
This commit is contained in:
commit
72bfde9790
@ -97,7 +97,9 @@ FILE(GLOB SRC_H include/git2/*.h)
|
||||
# On Windows use specific platform sources
|
||||
IF (WIN32 AND NOT CYGWIN)
|
||||
ADD_DEFINITIONS(-DWIN32 -D_DEBUG -D_WIN32_WINNT=0x0501)
|
||||
FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/win32/*.c)
|
||||
FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/win32/*.c src/compat/*.c)
|
||||
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
|
||||
FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/unix/*.c src/compat/*.c)
|
||||
ELSE()
|
||||
FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/unix/*.c)
|
||||
ENDIF ()
|
||||
|
@ -77,7 +77,7 @@ GIT_BEGIN_DECL
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The maximum length of a git valid git path.
|
||||
* The maximum length of a valid git path.
|
||||
*/
|
||||
#define GIT_PATH_MAX 4096
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_fnmatch__w32_h__
|
||||
#define INCLUDE_fnmatch__w32_h__
|
||||
#ifndef INCLUDE_fnmatch__compat_h__
|
||||
#define INCLUDE_fnmatch__compat_h__
|
||||
|
||||
#include "common.h"
|
||||
|
@ -306,7 +306,7 @@ static int _rmdir_recurs_foreach(void *opaque, git_buf *path)
|
||||
return -1;
|
||||
|
||||
if (p_rmdir(path->ptr) < 0) {
|
||||
if (removal_type == GIT_DIRREMOVAL_ONLY_EMPTY_DIRS && errno == ENOTEMPTY)
|
||||
if (removal_type == GIT_DIRREMOVAL_ONLY_EMPTY_DIRS && (errno == ENOTEMPTY || errno == EEXIST))
|
||||
return 0;
|
||||
|
||||
giterr_set(GITERR_OS, "Could not remove directory '%s'", path->ptr);
|
||||
|
33
src/path.c
33
src/path.c
@ -494,7 +494,7 @@ int git_path_direach(
|
||||
{
|
||||
ssize_t wd_len;
|
||||
DIR *dir;
|
||||
struct dirent de_buf, *de;
|
||||
struct dirent *de, *de_buf;
|
||||
|
||||
if (git_path_to_dir(path) < 0)
|
||||
return -1;
|
||||
@ -506,14 +506,23 @@ int git_path_direach(
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (p_readdir_r(dir, &de_buf, &de) == 0 && de != NULL) {
|
||||
#ifdef __sun
|
||||
de_buf = git__malloc(sizeof(struct dirent) + FILENAME_MAX + 1);
|
||||
#else
|
||||
de_buf = git__malloc(sizeof(struct dirent));
|
||||
#endif
|
||||
|
||||
while (p_readdir_r(dir, de_buf, &de) == 0 && de != NULL) {
|
||||
int result;
|
||||
|
||||
if (is_dot_or_dotdot(de->d_name))
|
||||
continue;
|
||||
|
||||
if (git_buf_puts(path, de->d_name) < 0)
|
||||
if (git_buf_puts(path, de->d_name) < 0) {
|
||||
closedir(dir);
|
||||
git__free(de_buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = fn(arg, path);
|
||||
|
||||
@ -521,11 +530,13 @@ int git_path_direach(
|
||||
|
||||
if (result < 0) {
|
||||
closedir(dir);
|
||||
git__free(de_buf);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
git__free(de_buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -537,7 +548,7 @@ int git_path_dirload(
|
||||
{
|
||||
int error, need_slash;
|
||||
DIR *dir;
|
||||
struct dirent de_buf, *de;
|
||||
struct dirent *de, *de_buf;
|
||||
size_t path_len;
|
||||
|
||||
assert(path != NULL && contents != NULL);
|
||||
@ -549,11 +560,17 @@ int git_path_dirload(
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef __sun
|
||||
de_buf = git__malloc(sizeof(struct dirent) + FILENAME_MAX + 1);
|
||||
#else
|
||||
de_buf = git__malloc(sizeof(struct dirent));
|
||||
#endif
|
||||
|
||||
path += prefix_len;
|
||||
path_len -= prefix_len;
|
||||
need_slash = (path_len > 0 && path[path_len-1] != '/') ? 1 : 0;
|
||||
|
||||
while ((error = p_readdir_r(dir, &de_buf, &de)) == 0 && de != NULL) {
|
||||
while ((error = p_readdir_r(dir, de_buf, &de)) == 0 && de != NULL) {
|
||||
char *entry_path;
|
||||
size_t entry_len;
|
||||
|
||||
@ -573,11 +590,15 @@ int git_path_dirload(
|
||||
memcpy(&entry_path[path_len + need_slash], de->d_name, entry_len);
|
||||
entry_path[path_len + need_slash + entry_len] = '\0';
|
||||
|
||||
if (git_vector_insert(contents, entry_path) < 0)
|
||||
if (git_vector_insert(contents, entry_path) < 0) {
|
||||
closedir(dir);
|
||||
git__free(de_buf);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
git__free(de_buf);
|
||||
|
||||
if (error != 0)
|
||||
giterr_set(GITERR_OS, "Failed to process directory entry in '%s'", path);
|
||||
|
@ -7,7 +7,14 @@
|
||||
#ifndef INCLUDE_posix__w32_h__
|
||||
#define INCLUDE_posix__w32_h__
|
||||
|
||||
#include <fnmatch.h>
|
||||
#ifndef __sun
|
||||
# include <fnmatch.h>
|
||||
# define p_fnmatch(p, s, f) fnmatch(p, s, f)
|
||||
#else
|
||||
# include "compat/fnmatch.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define p_lstat(p,b) lstat(p,b)
|
||||
#define p_readlink(a, b, c) readlink(a, b, c)
|
||||
@ -16,7 +23,6 @@
|
||||
#define p_mkdir(p,m) mkdir(p, m)
|
||||
#define p_fsync(fd) fsync(fd)
|
||||
#define p_realpath(p, po) realpath(p, po)
|
||||
#define p_fnmatch(p, s, f) fnmatch(p, s, f)
|
||||
#define p_vsnprintf(b, c, f, a) vsnprintf(b, c, f, a)
|
||||
#define p_snprintf(b, c, f, ...) snprintf(b, c, f, __VA_ARGS__)
|
||||
#define p_mkstemp(p) mkstemp(p)
|
||||
|
@ -8,7 +8,7 @@
|
||||
#define INCLUDE_posix__w32_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "fnmatch.h"
|
||||
#include "compat/fnmatch.h"
|
||||
#include "utf-conv.h"
|
||||
|
||||
GIT_INLINE(int) p_link(const char *old, const char *new)
|
||||
|
@ -222,3 +222,14 @@ void test_core_dirent__traverse_weird_filenames(void)
|
||||
|
||||
check_counts(&odd);
|
||||
}
|
||||
|
||||
/* test filename length limits */
|
||||
void test_core_dirent__length_limits(void)
|
||||
{
|
||||
char *big_filename = (char *)git__malloc(FILENAME_MAX + 1);
|
||||
memset(big_filename, 'a', FILENAME_MAX + 1);
|
||||
big_filename[FILENAME_MAX] = 0;
|
||||
|
||||
cl_must_fail(p_creat(big_filename, 0666));
|
||||
git__free(big_filename);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user