Re: memcmp() checker: memory access errors
- From: rlb@xxxxxxxxxxxxxxxxxxxxxx (Richard Bos)
- Date: Mon, 18 Dec 2006 16:19:27 GMT
malc <malc@xxxxxxxxxxxxx> wrote:
"kolmogolov@xxxxxxxxx" <kolmogolov@xxxxxxxxx> writes:
[..snip..]
int probe_img(FILE *fp)
{
unsigned char *data;
unsigned char KDF_header[4]={0x01, 0x03, 0x13, 0x5E};
int probe_len = 256;
int type=-1;
data = malloc( probe_len );
assert ( NULL != data );
assert ( 1 == fread(data, probe_len, 1, fp) );
if ( !memcmp(data, KDF_header, 4) )
{
type = 3;
}
return type;
}
There's a memory leak here. But as far as i can see that's not what
checker complains about.
Doesn't even get there. I'm beginning to suspect that what Checker
checked is not the posted code.
And excessive reading of 256 bytes where you really need 4 should be
self evident.
Not necessarily; if the rest of the header is needed by the rest of the
function, which just happens not to be written yet, it may be the right
size to read for the (as yet to be) completed code.
Richard
.
- Follow-Ups:
- Re: memcmp() checker: memory access errors
- From: kolmogolov@xxxxxxxxx
- Re: memcmp() checker: memory access errors
- References:
- memcmp() checker: memory access errors
- From: kolmogolov@xxxxxxxxx
- Re: memcmp() checker: memory access errors
- From: malc
- memcmp() checker: memory access errors
- Prev by Date: Re: how to get rid of warning (due to passing multidimensional array)
- Next by Date: Re: VLA feature of C99 vs malloc
- Previous by thread: Re: memcmp() checker: memory access errors
- Next by thread: Re: memcmp() checker: memory access errors
- Index(es):
Relevant Pages
|