From: zooko <zooko@zooko.com>
Date: Thu, 27 Sep 2007 22:55:34 +0000 (+0530)
Subject: zfec: don't use vsnprintf (because it is named _vsnprintf and has slightly different... 
X-Git-Url: https://git.rkrishnan.org/simplejson/components/com_hotproperty/status?a=commitdiff_plain;h=043d3bc72689e464929e2b8da7efa97e08c9d853;p=tahoe-lafs%2Fzfec.git

zfec: don't use vsnprintf (because it is named _vsnprintf and has slightly different semantics in the Microsoft C library) -- vsprintf is good enough for this purpose

darcs-hash:5119f21d54da904a47f1a664c7d67eeeca0823b6
---

diff --git a/zfec/zfec/_fecmodule.c b/zfec/zfec/_fecmodule.c
index 9050300..4939a8c 100644
--- a/zfec/zfec/_fecmodule.c
+++ b/zfec/zfec/_fecmodule.c
@@ -20,13 +20,14 @@ static char fec__doc__[] = "\
 FEC - Forward Error Correction \n\
 ";
 
+/* NOTE: if the complete expansion of the args (by vsprintf) exceeds 1024 then memory will be invalidly overwritten. */
 static PyObject *
 py_raise_fec_error(const char *format, ...) {
     char exceptionMsg[1024];
     va_list ap;
 
     va_start (ap, format);
-    vsnprintf (exceptionMsg, 1024, format, ap);
+    vsprintf (exceptionMsg, format, ap); /* Make sure that this can't exceed 1024 chars! */
     va_end (ap);
     exceptionMsg[1023]='\0';
     PyErr_SetString (py_fec_error, exceptionMsg);