Commit f2c24713 by nulltoken Committed by Vicent Marti

Made path prettifying functions return GIT_EINVALIDPATH instead of GIT_ERROR.

parent 2e6fd09c
......@@ -19,6 +19,7 @@ static struct {
{GIT_EFLOCKFAIL, "Failed to adquire or release a file lock"},
{GIT_EZLIB, "The Z library failed to inflate/deflate an object's data"},
{GIT_EBUSY, "The queried object is currently busy"},
{GIT_EINVALIDPATH, "The path is invalid"},
};
const char *git_strerror(int num)
......
......@@ -438,7 +438,7 @@ int gitfo_prettify_dir_path(char *buffer_out, const char *path)
*buffer_out ='\0';
len = retrieve_previous_path_component_start(buffer_out_start);
if (len < GIT_SUCCESS)
return GIT_ERROR;
return GIT_EINVALIDPATH;
buffer_out = (char *)buffer_out_start + len;
continue;
......@@ -446,7 +446,7 @@ int gitfo_prettify_dir_path(char *buffer_out, const char *path)
/* Guard against potential multiple dot path traversal (cf http://cwe.mitre.org/data/definitions/33.html) */
if (only_dots &&segment_len > 0)
return GIT_ERROR;
return GIT_EINVALIDPATH;
*buffer_out++ = '/';
len++;
......@@ -467,7 +467,7 @@ int gitfo_prettify_file_path(char *buffer_out, const char *path)
/* Let's make sure the filename doesn't end with "/", "/." or "/.." */
for (i = 1; path_len > i && i < 4; i++) {
if (!strncmp(path + path_len - i, pattern, i))
return GIT_ERROR;
return GIT_EINVALIDPATH;
}
error = gitfo_prettify_dir_path(buffer_out, path);
......@@ -476,7 +476,7 @@ int gitfo_prettify_file_path(char *buffer_out, const char *path)
path_len = strlen(buffer_out);
if (path_len < 2)
return GIT_ERROR;
return GIT_EINVALIDPATH;
/* Remove the trailing slash */
buffer_out[path_len - 1] = '\0';
......
......@@ -136,6 +136,9 @@
/** The index file is not backed up by an existing repository */
#define GIT_EBAREINDEX (GIT_ERROR -14)
/** The path is invalid */
#define GIT_EINVALIDPATH (GIT_ERROR - 19)
GIT_BEGIN_DECL
/** @} */
GIT_END_DECL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment