commit f7d20e8910435defc9367c68c5af4418123d088e from: Stefan Sperling date: Sun Jun 17 09:55:08 2018 UTC make got_canonpath() return a got_error commit - e6eac3b8ebc595e916b1133437b204ca21ebee29 commit + f7d20e8910435defc9367c68c5af4418123d088e blob - 435ee1d97e2cbf7f07b5608aec1e115279fc7850 blob + af1767503396d95abc5ad97aeaf9ecc73226817f --- lib/got_lib_path.h +++ lib/got_lib_path.h @@ -39,4 +39,4 @@ char *got_path_normalize(const char *); * and resolving references to parent directories ("/../"). * Relative paths are copied from input to buf as-is. */ -int got_canonpath(const char *input, char *buf, size_t bufsize) +const struct got_error *got_canonpath(const char *, char *, size_t); blob - fa26c7a7e5b5421a2282d81af15d789f189d004b blob + d14f81c3e51d80411824abe499bce05da745ce55 --- lib/path.c +++ lib/path.c @@ -64,8 +64,8 @@ got_path_normalize(const char *path) return resolved; } -/* canonpath() from kern_pledge.c */ -int +/* based on canonpath() from kern_pledge.c */ +const struct got_error * got_canonpath(const char *input, char *buf, size_t bufsize) { const char *p; @@ -74,8 +74,8 @@ got_canonpath(const char *input, char *buf, size_t buf /* can't canon relative paths, don't bother */ if (!got_path_is_absolute(input)) { if (strlcpy(buf, input, bufsize) >= bufsize) - return ENAMETOOLONG; - return 0; + return got_error(GOT_ERR_NO_SPACE); + return NULL; } p = input; @@ -101,7 +101,7 @@ got_canonpath(const char *input, char *buf, size_t buf } if ((*p == '\0') && (q - buf < bufsize)) { *q = 0; - return 0; + return NULL; } else - return ENAMETOOLONG; + return got_error(GOT_ERR_NO_SPACE); }