Bug 10734 - opcodes/avr-dis.c fails to compile on OS X 10.6.1 / XCode 3.2
Summary: opcodes/avr-dis.c fails to compile on OS X 10.6.1 / XCode 3.2
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.19
: P2 critical
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-06 10:30 UTC by Melanie Rhianna Lewis
Modified: 2009-10-06 11:03 UTC (History)
1 user (show)

See Also:
Host: osx
Target: avr
Build: osx
Last reconfirmed:


Attachments
A patch to fix the sprintf() literal string issue. (476 bytes, text/plain)
2009-10-06 10:31 UTC, Melanie Rhianna Lewis
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Melanie Rhianna Lewis 2009-10-06 10:30:11 UTC
I was trying to compile binutils 2.19.1 with the following configure options:

'--prefix=/usr/local/avr' '--target=avr' '--disable-nls'

On my MacBook (OS X 10.6.1) with gcc (i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 
5646)) and compilation of opcodes/avr-dis.c failed due to warnings re sprintf without string literals and 
warnings as errors enabled.  Converting the offending lines to strcpy()s fixes it.

Below is the patch to fix it.

diff -aur binutils-2.19.1.orig/opcodes/avr-dis.c binutils-2.19.1/opcodes/avr-dis.c
--- binutils-2.19.1.orig/opcodes/avr-dis.c	2007-07-05 10:49:00.000000000 +0100
+++ binutils-2.19.1/opcodes/avr-dis.c	2009-10-05 21:41:21.000000000 +0100
@@ -109,7 +109,7 @@
 	    case 0x100e: xyz = "-X"; break;
 	    default: xyz = "??"; ok = 0;
 	  }
-	sprintf (buf, xyz);
+	strcpy (buf, xyz);
 
 	if (AVR_UNDEF_P (insn))
 	  sprintf (comment, _("undefined"));
@@ -149,7 +149,7 @@
 	 value of the address only once, but this would mean recoding
 	 objdump_print_address() which would affect many targets.  */
       sprintf (buf, "%#lx", (unsigned long) *sym_addr);      
-      sprintf (comment, comment_start);
+      strcpy (comment, comment_start);
       break;
       
     case 'L':
@@ -158,7 +158,7 @@
 	sprintf (buf, ".%+-8d", rel_addr);
         *sym = 1;
         *sym_addr = pc + 2 + rel_addr;
-	sprintf (comment, comment_start);
+	strcpy (comment, comment_start);
       }
       break;
 
@@ -169,7 +169,7 @@
 	sprintf (buf, ".%+-8d", rel_addr);
         *sym = 1;
         *sym_addr = pc + 2 + rel_addr;
-	sprintf (comment, comment_start);
+	strcpy (comment, comment_start);
       }
       break;
Comment 1 Melanie Rhianna Lewis 2009-10-06 10:31:14 UTC
Created attachment 4257 [details]
A patch to fix the sprintf() literal string issue.

Attached patch that was in the bug report
Comment 2 gingold@adacore.com 2009-10-06 11:03:24 UTC
This has been fixed in the cvs repository since 2008-11-06.
(The fix will be included in the 2.20 release).