|
From: Tom H. <th...@cy...> - 2004-08-19 06:11:09
|
In message <412...@ci...>
Tom Hu <to...@ci...> wrote:
> xxx_validate_packet()
> {
> ...
> ...
> int rc = 0;
> if (!data) {
> return (XXX_ERROR_INVALID_PARAMETER);
> }
> xxx_debug_from_sa(sa, &debug);
> if (!receiver) xxx_log_hdr(&debug, data, receiver);
> hdr = (xxx_header *)data;
>
> /* The packet data length has to be the same as ike header length */
> if (len != ntohl(hdr->length)) {
> return XXX_INVALID_SYNTAX;
> }
>
> /* Validate spi */
> memset(spi_zero, 0x0, XXX_SPI_SIZE);
> /* Init spi MUST NOT be zero */
> rc = memcmp(hdr->init_spi, spi_zero, XXX_SPI_SIZE) ;
> =====> line 1219
> /* if (memcmp(hdr->init_spi, spi_zero, XXX_SPI_SIZE) == 0) { */
> if (rc == 0) {
> ======> line 1221
> return XXX_INVALID_SYNTAX;
> ....
> ...
> ...
> }
>
> Basically, valgrind complains line 1219 and 1221. I do not see any
> problem in 1221. It looks like rc has been initilize when declaring. The
> only I suspect is memcmp() call. Are both complained the same problem
> from memcmp or not? If those are memcmp problem. What is the possibility
> reason? Should I ignore this? If yes, how to do that?
The first complaint is from inside memcmp so either the length you
gave is uninitialised or one or more of the bytes being compared is.
I assume XXX_SPI_SIZE is a defined constant, and spi_zero is clearly
initialised, so presumably hdr->init_spi is not fully defined.
If the memcmp comapres uninitialised values then it's result is also
effectively uninitialised so the comparison of rc with zero will also
generate a warning.
Tom
--
Tom Hughes (th...@cy...)
Software Engineer, Cyberscience Corporation
http://www.cyberscience.com/
|