fix joinpath(): use of global 'repodir', should be 'path'
use joinpath for another case.
This commit is contained in:
parent
2d8eb85f01
commit
543582034e
|
@ -30,6 +30,18 @@ pledge(const char *promises, const char *paths[])
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
joinpath(char *buf, size_t bufsiz, const char *path, const char *path2)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
|
||||||
|
r = snprintf(buf, bufsiz, "%s%s%s",
|
||||||
|
path, path[0] && path[strlen(path) - 1] != '/' ? "/" : "", path2);
|
||||||
|
if (r == -1 || (size_t)r >= bufsiz)
|
||||||
|
errx(1, "path truncated: '%s%s%s'",
|
||||||
|
path, path[0] && path[strlen(path) - 1] != '/' ? "/" : "", path2);
|
||||||
|
}
|
||||||
|
|
||||||
/* Escape characters below as HTML 2.0 / XML 1.0. */
|
/* Escape characters below as HTML 2.0 / XML 1.0. */
|
||||||
void
|
void
|
||||||
xmlencode(FILE *fp, const char *s, size_t len)
|
xmlencode(FILE *fp, const char *s, size_t len)
|
||||||
|
@ -139,18 +151,6 @@ err:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
joinpath(char *buf, size_t bufsiz, const char *path, const char *path2)
|
|
||||||
{
|
|
||||||
int r;
|
|
||||||
|
|
||||||
r = snprintf(buf, bufsiz, "%s%s%s",
|
|
||||||
repodir, path[0] && path[strlen(path) - 1] != '/' ? "/" : "", path2);
|
|
||||||
if (r == -1 || (size_t)r >= bufsiz)
|
|
||||||
errx(1, "path truncated: '%s%s%s'",
|
|
||||||
path, path[0] && path[strlen(path) - 1] != '/' ? "/" : "", path2);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
37
stagit.c
37
stagit.c
|
@ -76,6 +76,18 @@ pledge(const char *promises, const char *paths[])
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
joinpath(char *buf, size_t bufsiz, const char *path, const char *path2)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
|
||||||
|
r = snprintf(buf, bufsiz, "%s%s%s",
|
||||||
|
path, path[0] && path[strlen(path) - 1] != '/' ? "/" : "", path2);
|
||||||
|
if (r == -1 || (size_t)r >= bufsiz)
|
||||||
|
errx(1, "path truncated: '%s%s%s'",
|
||||||
|
path, path[0] && path[strlen(path) - 1] != '/' ? "/" : "", path2);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
deltainfo_free(struct deltainfo *di)
|
deltainfo_free(struct deltainfo *di)
|
||||||
{
|
{
|
||||||
|
@ -796,17 +808,12 @@ writefilestree(FILE *fp, git_tree *tree, const char *branch, const char *path)
|
||||||
if (!(entry = git_tree_entry_byindex(tree, i)) ||
|
if (!(entry = git_tree_entry_byindex(tree, i)) ||
|
||||||
!(entryname = git_tree_entry_name(entry)))
|
!(entryname = git_tree_entry_name(entry)))
|
||||||
return -1;
|
return -1;
|
||||||
r = snprintf(entrypath, sizeof(entrypath), "%s%s%s",
|
joinpath(entrypath, sizeof(entrypath), path, entryname);
|
||||||
path, path[0] ? "/" : "", entryname);
|
|
||||||
if (r == -1 || (size_t)r >= sizeof(entrypath))
|
|
||||||
errx(1, "path truncated: '%s%s%s'",
|
|
||||||
path, path[0] ? "/" : "", entryname);
|
|
||||||
|
|
||||||
r = snprintf(filepath, sizeof(filepath), "file/%s%s%s.html",
|
r = snprintf(filepath, sizeof(filepath), "file/%s.html",
|
||||||
path, path[0] ? "/" : "", entryname);
|
entrypath);
|
||||||
if (r == -1 || (size_t)r >= sizeof(filepath))
|
if (r == -1 || (size_t)r >= sizeof(filepath))
|
||||||
errx(1, "path truncated: 'file/%s%s%s.html'",
|
errx(1, "path truncated: 'file/%s.html'", entrypath);
|
||||||
path, path[0] ? "/" : "", entryname);
|
|
||||||
|
|
||||||
if (!git_tree_entry_to_object(&obj, repo, entry)) {
|
if (!git_tree_entry_to_object(&obj, repo, entry)) {
|
||||||
switch (git_object_type(obj)) {
|
switch (git_object_type(obj)) {
|
||||||
|
@ -990,18 +997,6 @@ err:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
joinpath(char *buf, size_t bufsiz, const char *path, const char *path2)
|
|
||||||
{
|
|
||||||
int r;
|
|
||||||
|
|
||||||
r = snprintf(buf, bufsiz, "%s%s%s",
|
|
||||||
repodir, path[0] && path[strlen(path) - 1] != '/' ? "/" : "", path2);
|
|
||||||
if (r == -1 || (size_t)r >= bufsiz)
|
|
||||||
errx(1, "path truncated: '%s%s%s'",
|
|
||||||
path, path[0] && path[strlen(path) - 1] != '/' ? "/" : "", path2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
usage(char *argv0)
|
usage(char *argv0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue