X-Git-Url: https://git.armaanb.net/?a=blobdiff_plain;f=stagit-index.c;h=2b243ec15660ba042313d4317b2d33810f9300a3;hb=dd32948ba00cb30c852de72260255a5ebb24ccff;hp=accb1a534cb027dc08dc5f87e11a230a9f328523;hpb=3fbef5c9b0dee2106537a6718e2380eaa6e27f15;p=stagit.git diff --git a/stagit-index.c b/stagit-index.c index accb1a5..2b243ec 100644 --- a/stagit-index.c +++ b/stagit-index.c @@ -1,18 +1,13 @@ -#include - #include -#include -#include #include #include #include #include +#include #include #include -#include "compat.h" - static git_repository *repo; static const char *relpath = ""; @@ -28,7 +23,7 @@ joinpath(char *buf, size_t bufsiz, const char *path, const char *path2) r = snprintf(buf, bufsiz, "%s%s%s", path, path[0] && path[strlen(path) - 1] != '/' ? "/" : "", path2); - if (r == -1 || (size_t)r >= bufsiz) + if (r < 0 || (size_t)r >= bufsiz) errx(1, "path truncated: '%s%s%s'", path, path[0] && path[strlen(path) - 1] != '/' ? "/" : "", path2); } @@ -159,6 +154,10 @@ main(int argc, char *argv[]) git_libgit2_init(); #ifdef __OpenBSD__ + for (i = 1; i < argc; i++) + if (unveil(argv[i], "r") == -1) + err(1, "unveil: %s", argv[i]); + if (pledge("stdio rpath", NULL) == -1) err(1, "pledge"); #endif