Skip to contentSkip to conversation

ia64, ppc: Remove uses of sprintf().

Xen-staging Alex Williamson 2 participants 2 messages Jan 30, 2007 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

xen/arch/ia64/linux-xen/setup.c show_cpuinfo (struct seq_file *m, void * · line 554

Quoted 10 lines · Xen staging patchbot-unstable

diff -r 300c47bec138 -r bd69e83b65ea xen/arch/ia64/linux-xen/setup.c

xen/arch/ia64/linux-xen/setup.c +1 -1
@@ -550,7 +550,7 @@ show_cpuinfo (struct seq_file *m, void *
 	switch (c->family) {
 	      case 0x07:	memcpy(family, "Itanium", 8); break;
 	      case 0x1f:	memcpy(family, "Itanium 2", 10); break;
-	      default:		sprintf(family, "%u", c->family); break;
+	      default:		snprintf(family, sizeof(family), "%u", c->family); break;
 	}

What's the purpose of all this "cleanup"? This is just munging files
that we're leveraging from Linux, making updating them later on more difficult. And these really should have been submitted via the xen-ia64-devel list.

Alex

Signature · 1 line
Alex Williamson                             HP Open Source & Linux Org.
#2 lore raw
Quoted 4 lines · Alex Williamson

What's the purpose of all this "cleanup"? This is just munging files
that we're leveraging from Linux, making updating them later on more difficult. And these really should have been submitted via the xen-ia64-devel list.

The aim is to get rid of the 'dangerous' sprintf/strcat/strcpy functions. Obviously not all uses are unsafe but if we don't define them then dangerous uses can't creep in. There were already a few uses throughout Xen where overflow might have silently become a possibility in future (although none would be obviously exploitable). On the x86 side at least it turned out that only a few Linux-derived lines of code had to be modified which seems an acceptable price to pay.

If you still need those functions (do you still grab and munge a whole Linux tree to make Xen on ia64?) then you can define them just for ia64/linux-xen to provide a Linux-y environment, in which case it would make sense to revert any removal patches applied in that subtree.

-- Keir