[openssl-dev] [openssl.org #4489] PATCH: fix Windows deprecated strdup in crypto\conf\conf_lib.c

2016-05-25 Thread Richard Levitte via RT
On Tue Mar 29 12:02:41 2016, noloa...@gmail.com wrote:
> >>> $ cat conf_lib.patch
> >>> diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c
> >>> index f197714..7bc3ac0 100644
> >>> --- a/crypto/conf/conf_lib.c
> >>> +++ b/crypto/conf/conf_lib.c
> >>> @@ -392,7 +392,7 @@ void
> >>> OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings,
> >>> const char *config_file)
> >>> {
> >>> free(settings->config_name);
> >>> - settings->config_name = config_file == NULL ? NULL :
> >>> strdup(config_file);
> >>> + settings->config_name = config_file == NULL ? NULL :
> >>> OPENSSL_strdup(config_file);
> >>> }
> >>> #endif
> >>
> >> If you're going to change strdup -> OPENSSL_strdup, then the
> >> previous
> >> line needs to also change free -> OPENSSL_free.
> >
> > Few lines up there is rationale for malloc/free and by association
> > strdup. Switching to OPENSSL_[strdup|malloc|free] goes against it. On
> > Windows one can/should switch to _strdup (it also solves another real
> > yet subtle problem, not just warning). If lack of strdup is concern
> > (relly? which Fedora, BSD, Linux can it be?), then one might have to
> > consider local few-liner implementation. And conf_sap.c suffers from
> > this too...
>
> The odd thing with this one was, the switch from strdup to _strdup
> should have occurred with the patch from Issue 4488 occurred. For some
> reason, the text substitution was not occurring, even after including
> the header "openssl/e_os.h" in conf_lib.c.

It should be just "e_os.h"

I just tried, and it worked. With your patch, no more ISO C++ function
warnings.

I'll make a pull request in a few...

>
> I'm probably missing some other interaction among the headers.
>
> For completeness, below is the thrust of the 4488 patch. If
> Microsoft's compiler is from Visual Studio 2003 or above, then follow
> Microsoft's recommendations reported in the warning.
>
> ***
>
> $ git diff e_os.h > e_os.patch
> $ cat e_os.patch
> diff --git a/e_os.h b/e_os.h
> index f0a441e..1fe3ffb 100644
> --- a/e_os.h
> +++ b/e_os.h
> @@ -520,6 +520,13 @@ struct servent *PASCAL getservbyname(const char
> *, const char *);
> # if defined(OPENSSL_SYS_WINDOWS)
> # define strcasecmp _stricmp
> # define strncasecmp _strnicmp
> +# if (_MSC_VER >= 1310)
> +# define open _open
> +# define fdopen _fdopen
> +# define close _close
> +# define strdup _strdup
> +# define unlink _unlink
> +# endif
>
> # elif defined(OPENSSL_SYS_VMS)
> /* VMS below version 7.0 doesn't have strcasecmp() */
> # include "internal/o_str.h"


--
Richard Levitte
levi...@openssl.org

-- 
Ticket here: http://rt.openssl.org/Ticket/Display.html?id=4489
Please log in as guest with password guest if prompted

-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] [openssl.org #4489] PATCH: fix Windows deprecated strdup in crypto\conf\conf_lib.c

2016-03-29 Thread Kaduk, Ben via RT
On 03/29/2016 08:58 AM, noloa...@gmail.com via RT wrote:
> On Tue, Mar 29, 2016 at 9:53 AM, Salz, Rich via RT  wrote:
>> We use strdup because none of the openssl machinery (error stack, etc) might 
>> be set up yet.
>>
>> The comment a few lines above says this!
> Thanks.
>
> That does not explain why this had not effect on Windows, even after
> including "openssl/e_os.h":
>
> # define strdup _strdup
>
> It cleared the warning at other places, but not conf_lib.c.
>

Did you look at the cc -E output for the file in question to see whether
something was preventing the #define from taking effect?

-Ben


-- 
Ticket here: http://rt.openssl.org/Ticket/Display.html?id=4489
Please log in as guest with password guest if prompted

-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] [openssl.org #4489] PATCH: fix Windows deprecated strdup in crypto\conf\conf_lib.c

2016-03-29 Thread noloa...@gmail.com via RT
On Tue, Mar 29, 2016 at 9:53 AM, Salz, Rich via RT  wrote:
> We use strdup because none of the openssl machinery (error stack, etc) might 
> be set up yet.
>
> The comment a few lines above says this!

Thanks.

That does not explain why this had not effect on Windows, even after
including "openssl/e_os.h":

# define strdup _strdup

It cleared the warning at other places, but not conf_lib.c.

Jeff


-- 
Ticket here: http://rt.openssl.org/Ticket/Display.html?id=4489
Please log in as guest with password guest if prompted

-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] [openssl.org #4489] PATCH: fix Windows deprecated strdup in crypto\conf\conf_lib.c

2016-03-29 Thread Jeffrey Walton
On Tue, Mar 29, 2016 at 9:53 AM, Salz, Rich via RT  wrote:
> We use strdup because none of the openssl machinery (error stack, etc) might 
> be set up yet.
>
> The comment a few lines above says this!

Thanks.

That does not explain why this had not effect on Windows, even after
including "openssl/e_os.h":

# define strdup _strdup

It cleared the warning at other places, but not conf_lib.c.

Jeff
-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] [openssl.org #4489] PATCH: fix Windows deprecated strdup in crypto\conf\conf_lib.c

2016-03-29 Thread Salz, Rich via RT
We use strdup because none of the openssl machinery (error stack, etc) might be 
set up yet.

The comment a few lines above says this!


-- 
Ticket here: http://rt.openssl.org/Ticket/Display.html?id=4489
Please log in as guest with password guest if prompted

-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] [openssl.org #4489] PATCH: fix Windows deprecated strdup in crypto\conf\conf_lib.c

2016-03-29 Thread noloa...@gmail.com via RT
>>> $ cat conf_lib.patch
>>> diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c
>>> index f197714..7bc3ac0 100644
>>> --- a/crypto/conf/conf_lib.c
>>> +++ b/crypto/conf/conf_lib.c
>>> @@ -392,7 +392,7 @@ void
>>> OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings,
>>>   const char *config_file)
>>> {
>>> free(settings->config_name);
>>> -settings->config_name = config_file == NULL ? NULL : 
>>> strdup(config_file);
>>> +settings->config_name = config_file == NULL ? NULL :
>>> OPENSSL_strdup(config_file);
>>> }
>>> #endif
>>
>> If you're going to change strdup -> OPENSSL_strdup, then the previous
>> line needs to also change free -> OPENSSL_free.
>
> Few lines up there is rationale for malloc/free and by association
> strdup. Switching to OPENSSL_[strdup|malloc|free] goes against it. On
> Windows one can/should switch to _strdup (it also solves another real
> yet subtle problem, not just warning). If lack of strdup is concern
> (relly? which Fedora, BSD, Linux can it be?), then one might have to
> consider local few-liner implementation. And conf_sap.c suffers from
> this too...

The odd thing with this one was, the switch from strdup to _strdup
should have occurred with the patch from Issue 4488 occurred. For some
reason, the text substitution was not occurring, even after including
the header "openssl/e_os.h" in conf_lib.c.

I'm probably missing some other interaction among the headers.

For completeness, below is the thrust of the 4488 patch. If
Microsoft's compiler is from Visual Studio 2003 or above, then follow
Microsoft's recommendations reported in the warning.

***

$ git diff e_os.h > e_os.patch
$ cat e_os.patch
diff --git a/e_os.h b/e_os.h
index f0a441e..1fe3ffb 100644
--- a/e_os.h
+++ b/e_os.h
@@ -520,6 +520,13 @@ struct servent *PASCAL getservbyname(const char
*, const char *);
 # if defined(OPENSSL_SYS_WINDOWS)
 #  define strcasecmp _stricmp
 #  define strncasecmp _strnicmp
+#  if (_MSC_VER >= 1310)
+#   define open _open
+#   define fdopen _fdopen
+#   define close _close
+#   define strdup _strdup
+#   define unlink _unlink
+#  endif

 # elif defined(OPENSSL_SYS_VMS)
 /* VMS below version 7.0 doesn't have strcasecmp() */
 #  include "internal/o_str.h"


-- 
Ticket here: http://rt.openssl.org/Ticket/Display.html?id=4489
Please log in as guest with password guest if prompted

-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] [openssl.org #4489] PATCH: fix Windows deprecated strdup in crypto\conf\conf_lib.c

2016-03-29 Thread Jeffrey Walton
>>> $ cat conf_lib.patch
>>> diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c
>>> index f197714..7bc3ac0 100644
>>> --- a/crypto/conf/conf_lib.c
>>> +++ b/crypto/conf/conf_lib.c
>>> @@ -392,7 +392,7 @@ void
>>> OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings,
>>>   const char *config_file)
>>> {
>>> free(settings->config_name);
>>> -settings->config_name = config_file == NULL ? NULL : 
>>> strdup(config_file);
>>> +settings->config_name = config_file == NULL ? NULL :
>>> OPENSSL_strdup(config_file);
>>> }
>>> #endif
>>
>> If you're going to change strdup -> OPENSSL_strdup, then the previous
>> line needs to also change free -> OPENSSL_free.
>
> Few lines up there is rationale for malloc/free and by association
> strdup. Switching to OPENSSL_[strdup|malloc|free] goes against it. On
> Windows one can/should switch to _strdup (it also solves another real
> yet subtle problem, not just warning). If lack of strdup is concern
> (relly? which Fedora, BSD, Linux can it be?), then one might have to
> consider local few-liner implementation. And conf_sap.c suffers from
> this too...

The odd thing with this one was, the switch from strdup to _strdup
should have occurred with the patch from Issue 4488 occurred. For some
reason, the text substitution was not occurring, even after including
the header "openssl/e_os.h" in conf_lib.c.

I'm probably missing some other interaction among the headers.

For completeness, below is the thrust of the 4488 patch. If
Microsoft's compiler is from Visual Studio 2003 or above, then follow
Microsoft's recommendations reported in the warning.

***

$ git diff e_os.h > e_os.patch
$ cat e_os.patch
diff --git a/e_os.h b/e_os.h
index f0a441e..1fe3ffb 100644
--- a/e_os.h
+++ b/e_os.h
@@ -520,6 +520,13 @@ struct servent *PASCAL getservbyname(const char
*, const char *);
 # if defined(OPENSSL_SYS_WINDOWS)
 #  define strcasecmp _stricmp
 #  define strncasecmp _strnicmp
+#  if (_MSC_VER >= 1310)
+#   define open _open
+#   define fdopen _fdopen
+#   define close _close
+#   define strdup _strdup
+#   define unlink _unlink
+#  endif

 # elif defined(OPENSSL_SYS_VMS)
 /* VMS below version 7.0 doesn't have strcasecmp() */
 #  include "internal/o_str.h"
-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] [openssl.org #4489] PATCH: fix Windows deprecated strdup in crypto\conf\conf_lib.c

2016-03-29 Thread Andy Polyakov via RT
On 03/28/16 15:16, Viktor Dukhovni via RT wrote:
> 
>> On Mar 28, 2016, at 4:38 AM, noloa...@gmail.com via RT  
>> wrote:
>>
>> On Windows, the fix below also depends upon the patch from Issue 4488
>> ("The POSIX name for this item is deprecated. Instead, use the ISO C++
>> conformant name...").
>>
>> This patch below also fixes some problems with the older standards on
>> Fedora, BSD and Linux.
>>
>> $ cat conf_lib.patch
>> diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c
>> index f197714..7bc3ac0 100644
>> --- a/crypto/conf/conf_lib.c
>> +++ b/crypto/conf/conf_lib.c
>> @@ -392,7 +392,7 @@ void
>> OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings,
>>   const char *config_file)
>> {
>> free(settings->config_name);
>> -settings->config_name = config_file == NULL ? NULL : 
>> strdup(config_file);
>> +settings->config_name = config_file == NULL ? NULL :
>> OPENSSL_strdup(config_file);
>> }
>> #endif
> 
> If you're going to change strdup -> OPENSSL_strdup, then the previous
> line needs to also change free -> OPENSSL_free.

Few lines up there is rationale for malloc/free and by association
strdup. Switching to OPENSSL_[strdup|malloc|free] goes against it. On
Windows one can/should switch to _strdup (it also solves another real
yet subtle problem, not just warning). If lack of strdup is concern
(relly? which Fedora, BSD, Linux can it be?), then one might have to
consider local few-liner implementation. And conf_sap.c suffers from
this too...


-- 
Ticket here: http://rt.openssl.org/Ticket/Display.html?id=4489
Please log in as guest with password guest if prompted

-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] [openssl.org #4489] PATCH: fix Windows deprecated strdup in crypto\conf\conf_lib.c

2016-03-28 Thread Viktor Dukhovni via RT

> On Mar 28, 2016, at 4:38 AM, noloa...@gmail.com via RT  
> wrote:
> 
> On Windows, the fix below also depends upon the patch from Issue 4488
> ("The POSIX name for this item is deprecated. Instead, use the ISO C++
> conformant name...").
> 
> This patch below also fixes some problems with the older standards on
> Fedora, BSD and Linux.
> 
> $ cat conf_lib.patch
> diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c
> index f197714..7bc3ac0 100644
> --- a/crypto/conf/conf_lib.c
> +++ b/crypto/conf/conf_lib.c
> @@ -392,7 +392,7 @@ void
> OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings,
>   const char *config_file)
> {
> free(settings->config_name);
> -settings->config_name = config_file == NULL ? NULL : strdup(config_file);
> +settings->config_name = config_file == NULL ? NULL :
> OPENSSL_strdup(config_file);
> }
> #endif

If you're going to change strdup -> OPENSSL_strdup, then the previous
line needs to also change free -> OPENSSL_free.

-- 
Viktor.


-- 
Ticket here: http://rt.openssl.org/Ticket/Display.html?id=4489
Please log in as guest with password guest if prompted

-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] [openssl.org #4489] PATCH: fix Windows deprecated strdup in crypto\conf\conf_lib.c

2016-03-28 Thread Viktor Dukhovni

> On Mar 28, 2016, at 4:38 AM, noloa...@gmail.com via RT  
> wrote:
> 
> On Windows, the fix below also depends upon the patch from Issue 4488
> ("The POSIX name for this item is deprecated. Instead, use the ISO C++
> conformant name...").
> 
> This patch below also fixes some problems with the older standards on
> Fedora, BSD and Linux.
> 
> $ cat conf_lib.patch
> diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c
> index f197714..7bc3ac0 100644
> --- a/crypto/conf/conf_lib.c
> +++ b/crypto/conf/conf_lib.c
> @@ -392,7 +392,7 @@ void
> OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings,
>   const char *config_file)
> {
> free(settings->config_name);
> -settings->config_name = config_file == NULL ? NULL : strdup(config_file);
> +settings->config_name = config_file == NULL ? NULL :
> OPENSSL_strdup(config_file);
> }
> #endif

If you're going to change strdup -> OPENSSL_strdup, then the previous
line needs to also change free -> OPENSSL_free.

-- 
Viktor.

-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


[openssl-dev] [openssl.org #4489] PATCH: fix Windows deprecated strdup in crypto\conf\conf_lib.c

2016-03-28 Thread noloa...@gmail.com via RT
On Windows, the fix below also depends upon the patch from Issue 4488
("The POSIX name for this item is deprecated. Instead, use the ISO C++
conformant name...").

This patch below also fixes some problems with the older standards on
Fedora, BSD and Linux.

$ cat conf_lib.patch
diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c
index f197714..7bc3ac0 100644
--- a/crypto/conf/conf_lib.c
+++ b/crypto/conf/conf_lib.c
@@ -392,7 +392,7 @@ void
OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings,
   const char *config_file)
 {
 free(settings->config_name);
-settings->config_name = config_file == NULL ? NULL : strdup(config_file);
+settings->config_name = config_file == NULL ? NULL :
OPENSSL_strdup(config_file);
 }
 #endif


-- 
Ticket here: http://rt.openssl.org/Ticket/Display.html?id=4489
Please log in as guest with password guest if prompted

-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev