Re: [PATCH 1/5] avoid parse_sha1_header() accessing memory out of bound

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Liu Yubao
Date: Tuesday, December 2, 2008 - 8:49 pm

Shawn O. Pearce wrote:

Seems you missed the cover letter sent as patch 0/5, all patches are explained
in the cover letter, sorry I sent them as separate topics by mistake.

This bound check is mainly for uncompressed loose object, a loose object
that just are uncompressed:

uncompressed loose object = inflate(loose object)
loose object = deflate(typename + <space> + size + '\0' + data)

I'm doing a defensive programming, for uncompressed loose object the mmapped
memory is passed to parse_sha1_header without being checked by inflateInit() first,
so there may be a SIGSEGV crash for a corrupted uncompressed loose object.


Isn't it easier to solve this problem in one place and maintain it? Maybe someday
someone forgets parse_sha1_header requires a null terminated buffer, and a corrupted
uncompressed loose object even doesn't have to be null terminated (if there will be
this kind of loose object).

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
two questions about the format of loose object, Liu Yubao, (Mon Dec 1, 1:00 am)
Re: two questions about the format of loose object, Junio C Hamano, (Mon Dec 1, 1:25 am)
Re: two questions about the format of loose object, Jakub Narebski, (Mon Dec 1, 4:32 am)
Re: two questions about the format of loose object, Nick Andrew, (Mon Dec 1, 5:16 am)
Re: two questions about the format of loose object, Shawn O. Pearce, (Mon Dec 1, 8:21 am)
Re: two questions about the format of loose object, Shawn O. Pearce, (Mon Dec 1, 8:32 am)
Re: [PATCH 4/5] support reading uncompressed loose object, Shawn O. Pearce, (Tue Dec 2, 8:58 am)
Re: [PATCH 5/5] support writing uncompressed loose object, Shawn O. Pearce, (Tue Dec 2, 9:07 am)
Re: [PATCH 1/5] avoid parse_sha1_header() accessing memory ..., Liu Yubao, (Tue Dec 2, 8:49 pm)
Re: two questions about the format of loose object, Nicolas Pitre, (Wed Dec 3, 5:54 pm)