type_from_string_gently: make sure length matches
commitb7994af0f92e6cf150544aebe3c3fc526faaf2c3
authorJeff King <peff@peff.net>
Fri, 17 Apr 2015 14:52:48 +0000 (17 10:52 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 17 Apr 2015 20:54:39 +0000 (17 13:54 -0700)
tree91f3353ce20796fea21fdf32e56ae8325924602e
parentfe8e3b71805cd13d139b62fa5a0c75387568c9ea
type_from_string_gently: make sure length matches

When commit fe8e3b7 refactored type_from_string to allow
input that was not NUL-terminated, it switched to using
strncmp instead of strcmp. But this means we check only the
first "len" bytes of the strings, and ignore any remaining
bytes in the object_type_string. We should make sure that it
is also "len" bytes, or else we would accept "comm" as
"commit", and so forth.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
object.c
t/t1007-hash-object.sh