]> granicus.if.org Git - clang/commitdiff
sprintf -> snprintf conversion, from Vladimir Kirillov
authorDouglas Gregor <dgregor@apple.com>
Tue, 9 Nov 2010 03:20:07 +0000 (03:20 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 9 Nov 2010 03:20:07 +0000 (03:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118478 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/DocumentXML.cpp
lib/Lex/PPMacroExpansion.cpp

index 894f230216f6bd0f4a982b9e8cb8aeab7920e338..e4526bab43c811972231b4e4b6170c4e82a66c63 100644 (file)
@@ -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;
index 93532d19eb62154553938d1e06751768852d9261..9fe5ab4847bea408791914cfb0a5b81e91b49c82 100644 (file)
@@ -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();
 }