LCOV - code coverage report
Current view: top level - libstb/secvar/test - secvar-test-pkcs7.c (source / functions) Hit Total Coverage
Test: skiboot.info Lines: 11 11 100.0 %
Date: 2024-01-02 21:04:04 Functions: 2 2 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
       2                 :            : /* Copyright 2021 IBM Corp. */
       3                 :            : 
       4                 :            : #define MBEDTLS_PKCS7_C
       5                 :            : #include "secvar_common_test.c"
       6                 :            : #include "../../crypto/pkcs7/pkcs7.c"
       7                 :            : 
       8                 :            : const char *secvar_test_name = "pkcs7";
       9                 :            : 
      10                 :          1 : int run_test()
      11                 :            : {
      12                 :          1 :         const unsigned char underrun_p7s[] = {0x30, 0x48};
      13                 :            :         mbedtls_pkcs7 pkcs7;
      14                 :            :         unsigned char *data;
      15                 :            :         int rc;
      16                 :            : 
      17                 :          1 :         mbedtls_pkcs7_init(&pkcs7);
      18                 :            :         /* The data must live in the heap, not the stack, for valgrind to
      19                 :            :            catch the overread. */
      20                 :          1 :         data = malloc(sizeof(underrun_p7s));
      21                 :          1 :         memcpy(data, underrun_p7s, sizeof(underrun_p7s));
      22                 :          1 :         rc = mbedtls_pkcs7_parse_der(data, sizeof(underrun_p7s), &pkcs7);
      23                 :          1 :         free(data);
      24                 :          1 :         ASSERT(0 > rc);
      25                 :            : 
      26                 :          1 :         return 0;
      27                 :            : }
      28                 :            : 
      29                 :          1 : int main(void)
      30                 :            : {
      31                 :          1 :         return run_test();
      32                 :            : }

Generated by: LCOV version 1.14