fasihul-iapp / doubango

Automatically exported from code.google.com/p/doubango
0 stars 0 forks source link

Test A.1.13 Stack Manipulation incorrectly report success when it failed #164

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

Please use labels and text to provide additional information.
Test A.1.13 Stack Manipulation incorrectly report success when it failed (note 
that it should have passed)

tests[] declares parameters as

      {

            //** 12**

            "A.1.13.  Stack Manipulation",

                  RFC4465_A_1_13__Stack_Manipulation,

                  324,

                  "",

                  40

      }

However it should be

      {

            //** 12**

            "A.1.13.  Stack Manipulation",

                  RFC4465_A_1_13__Stack_Manipulation,

                  324,

                  "\0x00\0x03\0x00\0x02\0x00\0x01\0x00\0x42\0x00\0x42\0x00\0x00\0x00\0x01\0x00\0x01",

                  40

      }

This test is marked as ‘xoutput: YES’ even though the expected output was 
nothing and output was received.

I think the error lies in the method

int startsWith(const char* buffer1, size_t size1, const char* buffer2, size_t 
size2)

{

      size_t i;

      if(size1 < size2) return 0;

      /* problem is when size 2 is zero, just drop through this loop and return 1 */

for(i = 0; i< size2; i++)

      {

            if(buffer1[i] != buffer2[i])

            {

                  return 0;

            }

      }

      return 1;

}

I think it needs to be updated to something like (note that I have not actually 
tested it)

int startsWith(const char* buffer1, size_t size1, const char* buffer2, size_t 
size2)

{

      size_t i;

if(size1 == 0 && size2 == 0) return 1; /* expected nothing and got nothing – 
OK */

if(size1 < size2) return 0;

if(size2 == 0) /* got something and checking against nothing – NOT OK */

{

return 0;

      }

      else

{

/* check that the first size2 bytes of buffer1 match buffer2 */

for(i = 0; i< size2; i++)

            {

                  if(buffer1[i] != buffer2[i])

                  {

                        return 0;

                  }

            }

            return 1;

      }

}

Original issue reported on code.google.com by boss...@yahoo.fr on 8 Jan 2013 at 11:36

GoogleCodeExporter commented 9 years ago

Original comment by boss...@yahoo.fr on 8 Jan 2013 at 11:36

GoogleCodeExporter commented 9 years ago

Original comment by boss...@yahoo.fr on 9 Jan 2013 at 2:49

GoogleCodeExporter commented 9 years ago
Fixed in SVN r805+
/!\Please note that some torture tests require previous ones and the first have 
to be started with clean manager state.

Original comment by boss...@yahoo.fr on 10 Jan 2013 at 12:45