From 7f26e0225dd559a83bca585e65c8bc816dd37301 Mon Sep 17 00:00:00 2001 From: "dveditz@cruzio.com" Date: Fri, 9 Nov 2007 14:54:35 -0800 Subject: [PATCH] bug 402150 prevent crash @nsDocument::RetrieveRelevantHeaders, r=wtc, r/sr=jst, a=beltzner --- content/base/src/nsDocument.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index ad3d4fb2c19d..d0f911f94122 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -46,6 +46,7 @@ */ #include "plstr.h" +#include "prprf.h" #include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestorUtils.h" @@ -5332,10 +5333,11 @@ nsDocument::RetrieveRelevantHeaders(nsIChannel *aChannel) PRExplodedTime prtime; PR_ExplodeTime(modDate, PR_LocalTimeParameters, &prtime); // "MM/DD/YYYY hh:mm:ss" - char formatedTime[20]; - if (sprintf(formatedTime, "%02d/%02d/%04d %02d:%02d:%02d", - prtime.tm_month + 1, prtime.tm_mday, prtime.tm_year, - prtime.tm_hour , prtime.tm_min, prtime.tm_sec)) { + char formatedTime[24]; + if (PR_snprintf(formatedTime, sizeof(formatedTime), + "%02ld/%02ld/%04hd %02ld:%02ld:%02ld", + prtime.tm_month + 1, prtime.tm_mday, prtime.tm_year, + prtime.tm_hour , prtime.tm_min, prtime.tm_sec)) { CopyASCIItoUTF16(nsDependentCString(formatedTime), mLastModified); } }