aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-11-09 03:20:07 +0000
committerDouglas Gregor <dgregor@apple.com>2010-11-09 03:20:07 +0000
commit5e0fb35232366d1956647c2e01ea183242fba28c (patch)
tree3a52891ff9c7b6b62c37e3f16bcc4a06d89e034c
parent9d21944b21a4cf31e08305695588807c8ea17a65 (diff)
sprintf -> snprintf conversion, from Vladimir Kirillov
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118478 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Frontend/DocumentXML.cpp2
-rw-r--r--lib/Lex/PPMacroExpansion.cpp6
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/Frontend/DocumentXML.cpp b/lib/Frontend/DocumentXML.cpp
index 894f230216..e4526bab43 100644
--- a/lib/Frontend/DocumentXML.cpp
+++ b/lib/Frontend/DocumentXML.cpp
@@ -104,7 +104,7 @@ std::string DocumentXML::escapeString(const char* pStr,
if (isprint(C))
value += C;
else {
- sprintf(buffer, "\\%03o", C);
+ snprintf(buffer, sizeof(buffer), "\\%03o", C);
value += buffer;
}
break;
diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp
index 93532d19eb..9fe5ab4847 100644
--- a/lib/Lex/PPMacroExpansion.cpp
+++ b/lib/Lex/PPMacroExpansion.cpp
@@ -497,8 +497,8 @@ static void ComputeDATE_TIME(SourceLocation &DATELoc, SourceLocation &TIMELoc,
"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
};
- char TmpBuffer[100];
- sprintf(TmpBuffer, "\"%s %2d %4d\"", Months[TM->tm_mon], TM->tm_mday,
+ char TmpBuffer[32];
+ snprintf(TmpBuffer, sizeof(TmpBuffer), "\"%s %2d %4d\"", Months[TM->tm_mon], TM->tm_mday,
TM->tm_year+1900);
Token TmpTok;
@@ -506,7 +506,7 @@ static void ComputeDATE_TIME(SourceLocation &DATELoc, SourceLocation &TIMELoc,
PP.CreateString(TmpBuffer, strlen(TmpBuffer), TmpTok);
DATELoc = TmpTok.getLocation();
- sprintf(TmpBuffer, "\"%02d:%02d:%02d\"", TM->tm_hour, TM->tm_min, TM->tm_sec);
+ snprintf(TmpBuffer, sizeof(TmpBuffer), "\"%02d:%02d:%02d\"", TM->tm_hour, TM->tm_min, TM->tm_sec);
PP.CreateString(TmpBuffer, strlen(TmpBuffer), TmpTok);
TIMELoc = TmpTok.getLocation();
}