From 99d149b30b639aeafb46fd30e597e17366df6df1 Mon Sep 17 00:00:00 2001 From: Jan David Mol <mol@astron.nl> Date: Fri, 22 Apr 2011 07:08:55 +0000 Subject: [PATCH] bug 1362: sprintf -> snprintf, and some defensive programming --- MAC/GCF/_PALlight/PMLlight/src/GCF_RTMyPropertySet.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MAC/GCF/_PALlight/PMLlight/src/GCF_RTMyPropertySet.cc b/MAC/GCF/_PALlight/PMLlight/src/GCF_RTMyPropertySet.cc index 92d2783e9ab..b3ef8906423 100644 --- a/MAC/GCF/_PALlight/PMLlight/src/GCF_RTMyPropertySet.cc +++ b/MAC/GCF/_PALlight/PMLlight/src/GCF_RTMyPropertySet.cc @@ -557,10 +557,10 @@ void GCFRTMyPropertySet::readTypeFile() char buffer[200]; system("chmod 777 genTypeInfo"); - sprintf(buffer, "./genTypeInfo %d %s", getpid(), _type.c_str()); + snprintf(buffer, sizeof buffer, "./genTypeInfo %d %s", getpid(), _type.c_str()); system(buffer); //# Try to pen the file - sprintf(buffer, "typeInfo_%d.dpl.tmp", getpid()); + snprintf(buffer, sizeof buffer, "typeInfo_%d.dpl.tmp", getpid()); pvssAsciiFile.open(buffer, ifstream::in); char asciiLine[1024]; @@ -568,7 +568,7 @@ void GCFRTMyPropertySet::readTypeFile() bool typeFound(false); //# Read the file line by line and convert it to Key Value pairs. - while (pvssAsciiFile.getline (asciiLine, 1024)) + while (pvssAsciiFile.getline (asciiLine, sizeof asciiLine)) { if (typesSectionFound) { @@ -592,7 +592,7 @@ void GCFRTMyPropertySet::readTypeFile() } } pvssAsciiFile.close(); - sprintf(buffer, "rm -f typeInfo_%d.dpl.tmp", getpid()); + snprintf(buffer, sizeof buffer, "rm -f typeInfo_%d.dpl.tmp", getpid()); system(buffer); } @@ -635,7 +635,7 @@ void buildTypeStructTree(const string path, delete [] elName; if (elType == 1 || elType == 41) // structure or type ref { - while (pvssAsciiFile.getline (asciiLine, 1024) && !readWithBuild) + while (pvssAsciiFile.getline (asciiLine, sizeof asciiLine) && !readWithBuild) { buildTypeStructTree(propName, pvssAsciiFile, asciiLine, propInfos); } -- GitLab