Re: memcmp() checker: memory access errors
- From: malc <malc@xxxxxxxxxxxxx>
- Date: Mon, 18 Dec 2006 16:13:01 +0000 (UTC)
"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.
[..snip..]
P.S. Dangerous usage of `assert' is addressed in the reply by Richard Bos.
And excessive reading of 256 bytes where you really need 4 should be
self evident.
--
vale
.
- Follow-Ups:
- Re: memcmp() checker: memory access errors
- From: Richard Bos
- Re: memcmp() checker: memory access errors
- References:
- memcmp() checker: memory access errors
- From: kolmogolov@xxxxxxxxx
- memcmp() checker: memory access errors
- Prev by Date: Re: <OT> Re: I have a doubt
- Next by Date: Re: tricky array problem !
- Previous by thread: Re: memcmp() checker: memory access errors
- Next by thread: Re: memcmp() checker: memory access errors
- Index(es):
Relevant Pages
|