summaryrefslogtreecommitdiff
path: root/src/ToolBox
diff options
context:
space:
mode:
authorJan Vorlicek <janvorli@microsoft.com>2016-12-09 00:51:19 +0100
committerGitHub <noreply@github.com>2016-12-09 00:51:19 +0100
commite58e3c5e0a527802bd5286c537dc3ed603317c1d (patch)
treedabb0caf55c65bfe141a91de2c64a4c22a3682c5 /src/ToolBox
parentbf4ed11eb5cee7123fd0c6fa5b60f09fe7adf23e (diff)
downloadcoreclr-e58e3c5e0a527802bd5286c537dc3ed603317c1d.tar.gz
coreclr-e58e3c5e0a527802bd5286c537dc3ed603317c1d.tar.bz2
coreclr-e58e3c5e0a527802bd5286c537dc3ed603317c1d.zip
Remove sscanf and sprintf usage (#8508)
* Remove sscanf * Remove sprintf
Diffstat (limited to 'src/ToolBox')
-rw-r--r--src/ToolBox/superpmi/superpmi-shared/mclist.cpp2
-rw-r--r--src/ToolBox/superpmi/superpmi/methodstatsemitter.cpp22
-rw-r--r--src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp6
3 files changed, 15 insertions, 15 deletions
diff --git a/src/ToolBox/superpmi/superpmi-shared/mclist.cpp b/src/ToolBox/superpmi/superpmi-shared/mclist.cpp
index 6a6f8701bf..511893fc96 100644
--- a/src/ToolBox/superpmi/superpmi-shared/mclist.cpp
+++ b/src/ToolBox/superpmi/superpmi-shared/mclist.cpp
@@ -237,7 +237,7 @@ void MCList::AddMethodToMCL(int methodIndex)
DWORD charCount = 0;
DWORD bytesWritten = 0;
- charCount = sprintf(strMethodIndex, "%d\r\n", methodIndex);
+ charCount = sprintf_s(strMethodIndex, sizeof(strMethodIndex), "%d\r\n", methodIndex);
if (!WriteFile(hMCLFile, strMethodIndex, charCount, &bytesWritten, nullptr) || bytesWritten != charCount)
{
diff --git a/src/ToolBox/superpmi/superpmi/methodstatsemitter.cpp b/src/ToolBox/superpmi/superpmi/methodstatsemitter.cpp
index 0a43f02dd9..5cebc97db4 100644
--- a/src/ToolBox/superpmi/superpmi/methodstatsemitter.cpp
+++ b/src/ToolBox/superpmi/superpmi/methodstatsemitter.cpp
@@ -50,11 +50,11 @@ void MethodStatsEmitter::Emit(int methodNumber, MethodContext *mc, ULONGLONG fir
if (mc->dumpMethodMD5HashToBuffer(md5Hash, MD5_HASH_BUFFER_SIZE) != MD5_HASH_BUFFER_SIZE)
md5Hash[0] = 0;
- charCount += sprintf(rowData + charCount, "%s,", md5Hash);
+ charCount += sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%s,", md5Hash);
}
if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'n') != NULL || strchr(statsTypes, 'N') != NULL)
{
- charCount += sprintf(rowData + charCount, "%d,", methodNumber);
+ charCount += sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%d,", methodNumber);
}
if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'i') != NULL || strchr(statsTypes, 'I') != NULL)
{
@@ -63,7 +63,7 @@ void MethodStatsEmitter::Emit(int methodNumber, MethodContext *mc, ULONGLONG fir
unsigned flags = 0;
mc->repCompileMethod(&info, &flags);
- charCount += sprintf(rowData + charCount, "%d,", info.ILCodeSize);
+ charCount += sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%d,", info.ILCodeSize);
}
if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'a') != NULL || strchr(statsTypes, 'A') != NULL)
{
@@ -76,11 +76,11 @@ void MethodStatsEmitter::Emit(int methodNumber, MethodContext *mc, ULONGLONG fir
else
codeSize = 0;//this is likely a thin mc
- charCount += sprintf(rowData + charCount, "%d,", codeSize);
+ charCount += sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%d,", codeSize);
}
if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 't') != NULL || strchr(statsTypes, 'T') != NULL)
{
- charCount += sprintf(rowData + charCount, "%llu,%llu,", firstTime, secondTime);
+ charCount += sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%llu,%llu,", firstTime, secondTime);
}
//get rid of the final ',' and replace it with a '\n'
@@ -105,15 +105,15 @@ void MethodStatsEmitter::SetStatsTypes(char *types)
DWORD bytesWritten = 0;
if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'h') != NULL || strchr(statsTypes, 'H') != NULL)
- charCount += sprintf(rowHeader + charCount, "HASH,");
+ charCount += sprintf_s(rowHeader + charCount, _countof(rowHeader) - charCount, "HASH,");
if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'n') != NULL || strchr(statsTypes, 'N') != NULL)
- charCount += sprintf(rowHeader + charCount, "METHOD_NUMBER,");
+ charCount += sprintf_s(rowHeader + charCount, _countof(rowHeader) - charCount, "METHOD_NUMBER,");
if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'i') != NULL || strchr(statsTypes, 'I') != NULL)
- charCount += sprintf(rowHeader + charCount, "IL_CODE_SIZE,");
+ charCount += sprintf_s(rowHeader + charCount, _countof(rowHeader) - charCount, "IL_CODE_SIZE,");
if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'a') != NULL || strchr(statsTypes, 'A') != NULL)
- charCount += sprintf(rowHeader + charCount, "ASM_CODE_SIZE,");
+ charCount += sprintf_s(rowHeader + charCount, _countof(rowHeader) - charCount, "ASM_CODE_SIZE,");
if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 't') != NULL || strchr(statsTypes, 'T') != NULL)
- charCount += sprintf(rowHeader + charCount, "Time1,Time2,");
+ charCount += sprintf_s(rowHeader + charCount, _countof(rowHeader) - charCount, "Time1,Time2,");
//get rid of the final ',' and replace it with a '\n'
rowHeader[charCount - 1] = '\n';
@@ -123,4 +123,4 @@ void MethodStatsEmitter::SetStatsTypes(char *types)
LogError("Failed to write row header '%s'. GetLastError()=%u", rowHeader, GetLastError());
}
}
-} \ No newline at end of file
+}
diff --git a/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp b/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp
index 8c5232315e..301db3cfe9 100644
--- a/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp
+++ b/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp
@@ -138,7 +138,7 @@ bool WriteArrayToMCL(char *mclFilename, int *arr, int count)
DWORD charCount = 0;
DWORD bytesWritten = 0;
- charCount = sprintf(strMethodIndex, "%d\r\n", arr[i]);
+ charCount = sprintf_s(strMethodIndex, sizeof(strMethodIndex), "%d\r\n", arr[i]);
if (!WriteFile(hMCLFile, strMethodIndex, charCount, &bytesWritten, nullptr) || (bytesWritten != charCount))
{
@@ -232,7 +232,7 @@ void ProcessChildStdOut(const CommandLine::Options& o, char *stdoutFilename, int
if (o.applyDiff)
{
int temp1 = 0, temp2 = 0, temp3 = 0, temp4 = 0;
- int converted = sscanf(buff, g_AsmDiffsSummaryFormatString, &temp1, &temp2, &temp3, &temp4);
+ int converted = sscanf_s(buff, g_AsmDiffsSummaryFormatString, &temp1, &temp2, &temp3, &temp4);
if (converted != 4)
{
LogError("Couldn't parse status message: \"%s\"", buff);
@@ -248,7 +248,7 @@ void ProcessChildStdOut(const CommandLine::Options& o, char *stdoutFilename, int
else
{
int temp1 = 0, temp2 = 0, temp3 = 0;
- int converted = sscanf(buff, g_SummaryFormatString, &temp1, &temp2, &temp3);
+ int converted = sscanf_s(buff, g_SummaryFormatString, &temp1, &temp2, &temp3);
if (converted != 3)
{
LogError("Couldn't parse status message: \"%s\"", buff);