DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 21st August 2011
mgh21 mgh21 is offline
Real Name: Michael Hill
New User
 
Join Date: Aug 2011
Location: Australia
Posts: 7
Thanked 0 Times in 0 Posts
Default OpenBSD 4.9: strcpy warnings & FORTRAN compiler

Hello,

I have installed OpenBSD 4.9 (on a Dell Optiplex) to update the hardware for an application written in FORTRAN. I am using the GNU FORTRAN compiler from the packages collection. (g95-4.2.4p5v0.tgz ). Compiling produces warnings about misuse of strcpy(), sprintf() and strcat().

/usr/local/.../libgfortran.so.2.0: warning: strcpy() is almost always misused, please use strlcpy()

and similar for sprintf() and snprintf(), and strcat() and strlcat()

I assume that these warnings come from issues within the FORTRAN compiler, and hence cannot be fixed by changing the FORTRAN code.

Is there a way to stop these warnings from coming up, as they are annoying the owner of the FORTRAN application.


Thank-you,

Michael Hill
Reply With Quote
  #2   (View Single Post)  
Old 21st August 2011
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 3,148
Thanked 182 Times in 149 Posts
Default

The OpenBSD developers created strlcpy(3) as a safer version of strcpy(3). Unfortunately for some reason most of the Linux/GNU community does not accept these safer versions and stick to the old ones.

You mentioned the warnings only appear during compilation, so it is only a one time thing
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump

Last edited by J65nko; 23rd August 2011 at 09:08 AM.
Reply With Quote
  #3   (View Single Post)  
Old 21st August 2011
jggimi's Avatar
jggimi jggimi is online now
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 3,687
Thanked 214 Times in 189 Posts
Default

The GNU Fortran compiler depends upon the C library in OpenBSD's base, which produces those warning messages when strcpy(3) and the other insecure library functions are called during compilation.

If your customer does not want to see these messages, there are three options, as I see it. 1) port their application to another language, 2) use another OS, 3) customize the C library to eliminate the messages.

AFAIK, there is no other Fortran compiler for OpenBSD.
Reply With Quote
  #4   (View Single Post)  
Old 21st August 2011
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Helpful companion
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Thanked 193 Times in 184 Posts
Default

To be more specific, the warning is emitted by the GNU linker, it is used by OpenBSD to warn when deprecated or unsafe functions/symbols are referenced by programs.

The follow section of code from the C library.. lib/libc/string/strcpy.c.
Code:
#if defined(APIWARN)
__warn_references(strcpy,
    "warning: strcpy() is almost always misused, please use strlcpy()");
#endif
Expands to this, give or take a few quotes:
Code:
#if defined(APIWARN)
__asm__(".section .gnu.warning." __STRING(strcpy) " ; .ascii \"" warning: strcpy() is almost always misused, please use strlcpy() "\" ; .text");
#endif
Tell the owner the problem is unavoidable and is not harmful, the only possible way disable these warnings is to modify the C library. Don't do that.
Reply With Quote
  #5   (View Single Post)  
Old 23rd August 2011
mgh21 mgh21 is offline
Real Name: Michael Hill
New User
 
Join Date: Aug 2011
Location: Australia
Posts: 7
Thanked 0 Times in 0 Posts
Default

Thank-you for the clarification. I will let him know that it is not going to cause him any problems with his application.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenBSD/pf without compiler HOWTO update? zazen OpenBSD Installation and Upgrading 6 26th June 2011 06:47 AM
BSD licensed C, C++ and Fortran compiler released. BSDfan666 News 5 14th June 2011 04:03 PM
Build Process Warnings IronForge OpenBSD Installation and Upgrading 9 22nd January 2010 11:21 AM
pkg_chk c++ compiler not available fenrisW0lf NetBSD Package System (pkgsrc) 15 30th June 2008 10:48 AM
pcc compiler question ChineseBroccoli FreeBSD General 1 11th June 2008 11:29 PM


All times are GMT. The time now is 12:28 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick