Visual Studio 8 "insecure method" warnings

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Visual Studio 8 "insecure method" warnings

David Gobbi-2
Hi Everyone,

The VC++ 8.0 compiler warns about methods like strcpy, sscanf, sprintf,
because they lead to insecure code.  The microsoft documentation on the
issues is here:
http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx
though we can't use their microsoft-specific solution.

I have modified the VTK .h files so that packages can be built against
VTK without these warnings showing up, and will be checking in the
changes tomorrow morning.  The vtkSetString() macro in vtkSetGet.h was
the main offender.

There are plenty of uses of strcpy in the .cxx files, too.  I've added
a bug report (#2889) to cover this.

 - David


_______________________________________________
vtk-developers mailing list
[hidden email]
http://www.vtk.org/mailman/listinfo/vtk-developers
Reply | Threaded
Open this post in threaded view
|

Re: Visual Studio 8 "insecure method" warnings

William A. Hoffman
For CMake, we do this, in the top level cmakelist file:

# Disable deprecation warnings for standard C functions.
IF(CMAKE_COMPILER_2005)
  ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
ENDIF(CMAKE_COMPILER_2005)


At 05:30 PM 2/15/2006, David Gobbi wrote:

>Hi Everyone,
>
>The VC++ 8.0 compiler warns about methods like strcpy, sscanf, sprintf,
>because they lead to insecure code.  The microsoft documentation on the
>issues is here:
>http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx
>though we can't use their microsoft-specific solution.
>
>I have modified the VTK .h files so that packages can be built against
>VTK without these warnings showing up, and will be checking in the
>changes tomorrow morning.  The vtkSetString() macro in vtkSetGet.h was
>the main offender.
>
>There are plenty of uses of strcpy in the .cxx files, too.  I've added
>a bug report (#2889) to cover this.
>
>- David
>
>
>_______________________________________________
>vtk-developers mailing list
>[hidden email]
>http://www.vtk.org/mailman/listinfo/vtk-developers

_______________________________________________
vtk-developers mailing list
[hidden email]
http://www.vtk.org/mailman/listinfo/vtk-developers
Reply | Threaded
Open this post in threaded view
|

Re: Visual Studio 8 "insecure method" warnings

David Gobbi-2
Hi Bill,

Thanks, I can add this to the VTK CMakeLists as well.  That way only
cleaning
up the header files will be necessary.  The place we are seeing the
warnings is
in IGSTK, for which we have a policy of not disabling any valid warnings.

 - David


William A. Hoffman wrote:

>For CMake, we do this, in the top level cmakelist file:
>
># Disable deprecation warnings for standard C functions.
>IF(CMAKE_COMPILER_2005)
>  ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
>ENDIF(CMAKE_COMPILER_2005)
>
>
>At 05:30 PM 2/15/2006, David Gobbi wrote:
>  
>
>>Hi Everyone,
>>
>>The VC++ 8.0 compiler warns about methods like strcpy, sscanf, sprintf,
>>because they lead to insecure code.  The microsoft documentation on the
>>issues is here:
>>http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx
>>though we can't use their microsoft-specific solution.
>>
>>I have modified the VTK .h files so that packages can be built against
>>VTK without these warnings showing up, and will be checking in the
>>changes tomorrow morning.  The vtkSetString() macro in vtkSetGet.h was
>>the main offender.
>>
>>There are plenty of uses of strcpy in the .cxx files, too.  I've added
>>a bug report (#2889) to cover this.
>>
>>- David
>>
>>
>>_______________________________________________
>>vtk-developers mailing list
>>[hidden email]
>>http://www.vtk.org/mailman/listinfo/vtk-developers
>>    
>>
>
>
>  
>

_______________________________________________
vtk-developers mailing list
[hidden email]
http://www.vtk.org/mailman/listinfo/vtk-developers
Reply | Threaded
Open this post in threaded view
|

Re: Visual Studio 8 "insecure method" warnings

William A. Hoffman
At 10:30 AM 2/16/2006, David Gobbi wrote:
>Hi Bill,
>
>Thanks, I can add this to the VTK CMakeLists as well.  That way only cleaning
>up the header files will be necessary.  The place we are seeing the warnings is
>in IGSTK, for which we have a policy of not disabling any valid warnings.

IMO, these are not valid warnings.  Basically, the warnings mean stop using
the ANSI "C" language because it is unsafe.  So, unless you are willing to say
that IGSTK is no longer going to use ANSI C, the warnings are not valid.

-Bill

_______________________________________________
vtk-developers mailing list
[hidden email]
http://www.vtk.org/mailman/listinfo/vtk-developers
Reply | Threaded
Open this post in threaded view
|

Re: Visual Studio 8 "insecure method" warnings

David Gobbi-2
William A. Hoffman wrote:

>At 10:30 AM 2/16/2006, David Gobbi wrote:
>  
>
>>Hi Bill,
>>
>>Thanks, I can add this to the VTK CMakeLists as well.  That way only cleaning
>>up the header files will be necessary.  The place we are seeing the warnings is
>>in IGSTK, for which we have a policy of not disabling any valid warnings.
>>    
>>
>
>IMO, these are not valid warnings.  Basically, the warnings mean stop using
>the ANSI "C" language because it is unsafe.  So, unless you are willing to say
>that IGSTK is no longer going to use ANSI C, the warnings are not valid.
>  
>
That's pretty much what it boils down to.  For IGSTK the concern is that
even valid code
is not always safe code, and there is a strong push away from C arrays
and the C standard
library to the STL.

For a C programmer like myself the IGSTK code looks overly verbose, but
I've gradually
come to understand the reasoning behind it.

 - David


_______________________________________________
vtk-developers mailing list
[hidden email]
http://www.vtk.org/mailman/listinfo/vtk-developers
Reply | Threaded
Open this post in threaded view
|

RE: Visual Studio 8 "insecure method" warnings

Andrew J. Dolgert
In reply to this post by David Gobbi-2
The "Safer CRT" modifications aren't ANSI and aren't yet accepted into
future ANSI, the C99 standard. They are in an ISO proposal draft
technical report from September 2005 which hopes to place them in the
C99 standard. The draft is at
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1135.pdf
That makes the compiler's flagging of ANSI library functions as
deprecated a bit of a strong-arm practice. You can feel good about
turning off this warning.

- Drew Dolgert

_______________________________________________
vtk-developers mailing list
[hidden email]
http://www.vtk.org/mailman/listinfo/vtk-developers
Reply | Threaded
Open this post in threaded view
|

Re: Visual Studio 8 "insecure method" warnings

David Gobbi-2
I've committed the fix to turn off the warnings in VTK, and I've changed
vtkSetStringMacro so that it doesn't use "strcpy".  That should be enough
to keep the warnings from cropping up.

Andrew J. Dolgert wrote:

>The "Safer CRT" modifications aren't ANSI and aren't yet accepted into
>future ANSI, the C99 standard. They are in an ISO proposal draft
>technical report from September 2005 which hopes to place them in the
>C99 standard. The draft is at
>http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1135.pdf
>That makes the compiler's flagging of ANSI library functions as
>deprecated a bit of a strong-arm practice. You can feel good about
>turning off this warning.
>
>- Drew Dolgert
>
>_______________________________________________
>vtk-developers mailing list
>[hidden email]
>http://www.vtk.org/mailman/listinfo/vtk-developers
>  
>

_______________________________________________
vtk-developers mailing list
[hidden email]
http://www.vtk.org/mailman/listinfo/vtk-developers
Reply | Threaded
Open this post in threaded view
|

Re: Visual Studio 8 "insecure method" warnings

David Cole
In reply to this post by Andrew J. Dolgert
Andrew J. Dolgert wrote:

>...a bit of a strong-arm practice...
>  
>
And yet, strong-arm practices are not really all that surprising when
you are the primary target of most of the malicious hackers in the
world. You'll all want the warning back as soon as somebody's actively
exploited your call to strcpy...

strcpy is dead; long live strcpy
;)

_______________________________________________
vtk-developers mailing list
[hidden email]
http://www.vtk.org/mailman/listinfo/vtk-developers