commit 0e6ab4b2dda12fd56fa5ccb1cb3ff1aa12876891 from: Stefan Sperling date: Thu Mar 10 09:23:19 2022 UTC make got_repo_match_object_id_prefix() reject overlong input strings suggested by + ok naddy commit - 0ed2285b0119b293d6b77b882c707c0377e176cd commit + 0e6ab4b2dda12fd56fa5ccb1cb3ff1aa12876891 blob - 8885743e283c1cb4fc9c98d7c28f6d6732f33469 blob + d4175545865a20ba9a3cff43736298aaae5e8c37 --- lib/repository.c +++ lib/repository.c @@ -1671,13 +1671,16 @@ got_repo_match_object_id_prefix(struct got_object_id * *id = NULL; - for (i = 0; i < strlen(id_str_prefix); i++) { + len = strlen(id_str_prefix); + if (len > SHA1_DIGEST_STRING_LENGTH - 1) + return got_error_path(id_str_prefix, GOT_ERR_BAD_OBJ_ID_STR); + + for (i = 0; i < len; i++) { if (isxdigit((unsigned char)id_str_prefix[i])) continue; return got_error_path(id_str_prefix, GOT_ERR_BAD_OBJ_ID_STR); } - len = strlen(id_str_prefix); if (len >= 2) { err = match_packed_object(id, repo, id_str_prefix, obj_type); if (err)