Ticket #51451: patch-tests-pkcs11-pkcs11-mock.c.diff

File patch-tests-pkcs11-pkcs11-mock.c.diff, 1.0 KB (added by ballapete (Peter "Pete" Dyballa), 8 years ago)

Tiger compatible version of patch

  • tests/pkcs11/pkcs11-mock.

    old new  
    1616
    1717#include "pkcs11-mock.h"
    1818#include <stdlib.h>
     19 
     20# ifdef __APPLE__
     21# if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
     22#  include <Availability.h>
     23# endif
     24# if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1060
     25static char * strndup (char const *s, size_t n);
     26static size_t strnlen (const char *string, size_t maxlen);
     27
     28static size_t
     29strnlen (const char *string, size_t maxlen)
     30{
     31  const char *end = memchr (string, '\0', maxlen);
     32  return end ? (size_t) (end - string) : maxlen;
     33}
     34
     35static char *
     36strndup (char const *s, size_t n)
     37{
     38  size_t len = strnlen (s, n);
     39  char *new = malloc (len + 1);
     40
     41  if (new == NULL)
     42    return NULL;
     43
     44  new[len] = '\0';
     45  return memcpy (new, s, len);
     46}
     47# endif
     48#endif
    1949
    2050/* This is a very basic mock PKCS #11 module that will return a given fixed
    2151 * certificate, and public key for all searches. It will also provide a