commit dbdd620944b55aa6cbe81fede1db6443521ac3ec from: Stefan Sperling date: Mon Oct 19 23:14:59 2020 UTC handle non-const basename in resolve_symlink() ok millert commit - 4a26d3f877326c99bcf462b076800a112319ff6d commit + dbdd620944b55aa6cbe81fede1db6443521ac3ec blob - a13a191e043c94ff5f692e1f875fda3b1eb9cb21 blob + a8e56d3ae101b242e7f90d82f2276a5ab517a4fb --- lib/object.c +++ lib/object.c @@ -1855,6 +1855,7 @@ resolve_symlink(char **link_target, const char *path, struct got_object_id *commit_id, struct got_repository *repo) { const struct got_error *err = NULL; + char buf[PATH_MAX]; char *name, *parent_path = NULL; struct got_object_id *tree_obj_id = NULL; struct got_tree_object *tree = NULL; @@ -1862,7 +1863,10 @@ resolve_symlink(char **link_target, const char *path, *link_target = NULL; - name = basename(path); + if (strlcpy(buf, path, sizeof(buf)) >= sizeof(buf)) + return got_error(GOT_ERR_NO_SPACE); + + name = basename(buf); if (name == NULL) return got_error_from_errno2("basename", path);