Skip to content

Reading CHOICE name confuses valgrind

Description of problem:

Maybe this is a false-positive in valgrind, but it reports "Conditional jump or move depends on uninitialised value(s)" when I access a certain position of CHOICE node name returned by asn1_read_value, i.e.,

  data_size = sizeof(data);
  result = asn1_read_value (node2, "", data, &data_size);
  if (result != ASN1_SUCCESS)
    {
      printf ("error in %d\n", __LINE__);
      exit (1);
    }

  if (strcmp (data, "012345678901234") == 0) // <--
    {
      printf ("error in %d\n", __LINE__);
      exit (1);
    }

Interestingly, valgrind doesn't complain if the needle is shorter than 16 nor the program is compiled with -O0.

Version of libtasn1 used:

git master

Distributor of libtasn1 (e.g., Ubuntu, Fedora, RHEL)

How reproducible:

$ ./configure CFLAGS="-O2 -g3 -Wall"
$ make
$ make check LOG_COMPILER="valgrind --error-exitcode=1" TESTS=Test_choice V=1
$ cat tests/Test_choice.log

Actual results:

The log contains:

==1297== Conditional jump or move depends on uninitialised value(s)
==1297==    at 0x4013DD: main (Test_choice.c:122)

Expected results:

The log shouldn't contain the error.