External symbols beginning with "str" are reserved to the library by the C 
standard (ISO 9899-1999 et seq). It's a violation of the standard to define 
them outside the implementation. You should use function names in the user 
namespace and if necessary use value-style macros to replace the reserved names 
elsewhere in the source.

I suppose it's a bit quixotic to talk about the proper use of C in an OpenSSL 
forum, but trying to follow the rules (even in code that's not part of the 
library itself) would be a step in the right direction.

-- 
Michael Wojcik
Technology Specialist, Micro Focus


> -----Original Message-----
> From: owner-openssl-us...@openssl.org [mailto:owner-openssl-
> us...@openssl.org] On Behalf Of The Doctor,3328-138 Ave Edmonton AB T5Y
> 1M4,669-2000,473-4587
> Sent: Tuesday, 20 May, 2014 01:41
> To: openssl-...@openssl.org; openssl-users@openssl.org; openssl-
> c...@openssl.org
> Subject: test/heartbleed_test.c
> 
> Found that strndup would not work.
> 
> I had to add
> 
> #if !HAVE_STRNDUP
> 
> #include <stdio.h>
> #include <string.h>
> #include <sys/types.h>
> #include <malloc.h>
> 
> /* Find the length of STRING, but scan at most MAXLEN characters.
>    If no '\0' terminator is found in that many characters, return MAXLEN.  */
> size_t
> strnlen (const char *string, size_t maxlen)
> {
>   const char *end = memchr (string, '\0', maxlen);
>   return end ? end - string : maxlen;
> }
> 
> char *
> strndup (const char *s, size_t n)
> {
>   size_t len = strnlen (s, n);
>   char *new = malloc (len + 1);
> 
>   if (new == NULL)
>     return NULL;
> 
>   new[len] = '\0';
>   return memcpy (new, s, len);
> }
> 
> #endif
> 
> Please see how you can add this.
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    openssl-users@openssl.org
> Automated List Manager                           majord...@openssl.org


This message has been scanned for malware by Websense. www.websense.com
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to