commit cc483380c54d31f8ddf61787337cefe1ccf3581b from: Stefan Sperling date: Sun Sep 01 11:08:13 2019 UTC fix NULL deref in got_error_from_errno via got_error_uuid (found by jasper) commit - 12314ad41528fec74eb27b6f444791c2c06f39ef commit + cc483380c54d31f8ddf61787337cefe1ccf3581b blob - b156fbf00a432c54a36fa14acf4c334307dcdd17 blob + 97f04731b6ad9e1bccd53406696dab9612512659 --- include/got_error.h +++ include/got_error.h @@ -323,7 +323,7 @@ const struct got_error *got_error_no_obj(struct got_ob const struct got_error *got_error_not_ref(const char *); /* Return an error based on a uuid(3) status code. */ -const struct got_error *got_error_uuid(uint32_t); +const struct got_error *got_error_uuid(uint32_t, const char *); /* Return an error with a path prefixed to the error message. */ const struct got_error *got_error_path(const char *, int); blob - 1c3c04a41a6293e5796cc7ec1fedef8864ff0dcc blob + 92ce7a5fda79f0688485a4cd32be5ec5fd2dfa64 --- lib/error.c +++ lib/error.c @@ -157,7 +157,7 @@ got_error_not_ref(const char *refname) } const struct got_error * -got_error_uuid(uint32_t uuid_status) +got_error_uuid(uint32_t uuid_status, const char *prefix) { switch (uuid_status) { case uuid_s_ok: @@ -167,7 +167,7 @@ got_error_uuid(uint32_t uuid_status) case uuid_s_invalid_string_uuid: return got_error(GOT_ERR_UUID_INVALID); case uuid_s_no_memory: - return got_error_set_errno(ENOMEM, NULL); + return got_error_set_errno(ENOMEM, prefix); default: return got_error(GOT_ERR_UUID); } blob - 3991862f6937a45384001a29a872cbffe9b742e1 blob + 71909fdc0e45cdb4a1f34f21237d4504b723d1aa --- lib/worktree.c +++ lib/worktree.c @@ -284,12 +284,12 @@ got_worktree_init(const char *path, struct got_referen /* Generate UUID. */ uuid_create(&uuid, &uuid_status); if (uuid_status != uuid_s_ok) { - err = got_error_uuid(uuid_status); + err = got_error_uuid(uuid_status, "uuid_create"); goto done; } uuid_to_string(&uuid, &uuidstr, &uuid_status); if (uuid_status != uuid_s_ok) { - err = got_error_uuid(uuid_status); + err = got_error_uuid(uuid_status, "uuid_to_string"); goto done; } err = create_meta_file(path_got, GOT_WORKTREE_UUID, uuidstr); @@ -397,7 +397,7 @@ open_worktree(struct got_worktree **worktree, const ch goto done; uuid_from_string(uuidstr, &(*worktree)->uuid, &uuid_status); if (uuid_status != uuid_s_ok) { - err = got_error_uuid(uuid_status); + err = got_error_uuid(uuid_status, "uuid_from_string"); goto done; } @@ -1455,7 +1455,7 @@ get_ref_name(char **refname, struct got_worktree *work uuid_to_string(&worktree->uuid, &uuidstr, &uuid_status); if (uuid_status != uuid_s_ok) - return got_error_uuid(uuid_status); + return got_error_uuid(uuid_status, "uuid_to_string"); if (asprintf(refname, "%s-%s", prefix, uuidstr) == -1) {