Skip to contentSkip to conversation

2.4 vsnprintf fix.

PATCH In review Rusty Russell 2 participants 2 messages Sep 20, 2001 – Sep 21, 2001

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.4 vsnprintf fix.

Following patch fixes calling vsnprintf with (NULL, 0) to get the length of the string. The problem is that the end ptr is set to 0xFFFFFFFF in this case, causing a write into address 0 as start < end.

Cheers,
Rusty.
--
Premature optmztion is rt of all evl. --DK

lib/vsprintf.c renamed from lib/vsprintf.c.~1~ +2 -0
@@ -246,6 +246,8 @@
 				/* 'z' support added 23/7/1999 S.H.    */
 				/* 'z' changed to 'Z' --davidm 1/25/99 */
 
+	/* buf = NULL, size = 0 is common for getting length */
+	if (size == 0) buf = (void *)1;
 	str = buf;
 	end = buf + size - 1;
#1 lore raw

++ 20/09/01 21:29 +1000 - Rusty Russell:

Quoted 4 lines

Following patch fixes calling vsnprintf with (NULL, 0) to get the length of the string. The problem is that the end ptr is set to 0xFFFFFFFF in this case, causing a write into address 0 as start < end.

Doh! Egg on face. Between this and the sysrq bugs, I'm thinking of going into dance instead of hacking anymore. Sorry about this, it is a basic mistake (right up there with going up against a scicilian when death is on the line.)

Quoted 21 lines

Cheers,
Rusty.
--
Premature optmztion is rt of all evl. --DK

lib/vsprintf.c renamed from lib/vsprintf.c.~1~ +2 -1
@@ -246,6 +246,8 @@
 				/* 'z' support added 23/7/1999 S.H.    */
 				/* 'z' changed to 'Z' --davidm 1/25/99 */
 
+	/* buf = NULL, size = 0 is common for getting length */
+	if (size == 0) buf = (void *)1;
 	str = buf;
 	end = buf + size - 1;
-

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 3 lines
Crutcher        <[email protected]>
GCS d--- s+:>+:- a-- C++++$ UL++++$ L+++$>++++ !E PS+++ PE Y+ PGP+>++++
    R-(+++) !tv(+++) b+(++++) G+ e>++++ h+>++ r* y+>*$