From 290882e9b6cbe1054736b0eb85361f1c84ac812f Mon Sep 17 00:00:00 2001 From: ivana Date: Sat, 6 Nov 2010 11:11:52 +0000 Subject: [PATCH] Fixing SECURE_CODING (sprintf) defect reported by Coverity --- MUON/AliMUONTriggerGUI.cxx | 8 ++++---- MUON/mapping/AliMpDEVisu.cxx | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/MUON/AliMUONTriggerGUI.cxx b/MUON/AliMUONTriggerGUI.cxx index 08a182c62f0..156b2c2c50a 100644 --- a/MUON/AliMUONTriggerGUI.cxx +++ b/MUON/AliMUONTriggerGUI.cxx @@ -1951,8 +1951,8 @@ void AliMUONTriggerGUI::WriteTriggerRawData() char command[256]; char dateFileName[256]; - sprintf(dateFileName,"TriggerGUI.date"); - sprintf(command, "dateStream -c -s -D -o %s -# %d -C -run %d", + snprintf(dateFileName,256,"TriggerGUI.date"); + snprintf(command, 256,"dateStream -c -s -D -o %s -# %d -C -run %d", dateFileName, 1, 0); FILE* pipe = gSystem->OpenPipe(command, "w"); @@ -1970,7 +1970,7 @@ void AliMUONTriggerGUI::WriteTriggerRawData() ldc += AliDAQ::NumberOfLdcs(iDet) / AliDAQ::NumberOfDdls(iDet); char rawFileName[256]; - sprintf(rawFileName, "%s",AliDAQ::DdlFileName(iDet,iDDL)); + snprintf(rawFileName, 256,"%s",AliDAQ::DdlFileName(iDet,iDDL)); // check existence and size of raw data file FILE* file = fopen(rawFileName, "rb"); if (!file) continue; @@ -1992,7 +1992,7 @@ void AliMUONTriggerGUI::WriteTriggerRawData() // AliSimulation::ConvertDateToRoot char rootFileName[256]; - sprintf(rootFileName,"TriggerGUI.root"); + snprintf(rootFileName,256,"TriggerGUI.root"); // ALIMDC setup const Int_t kDBSize = 2000000000; diff --git a/MUON/mapping/AliMpDEVisu.cxx b/MUON/mapping/AliMpDEVisu.cxx index 5b94cd4f8f9..2fd08e745d7 100644 --- a/MUON/mapping/AliMpDEVisu.cxx +++ b/MUON/mapping/AliMpDEVisu.cxx @@ -55,6 +55,8 @@ #include #include +#include + // Category: graphics //----------------------------------------------------------------------------- @@ -145,7 +147,7 @@ AliMpDEVisu::AliMpDEVisu(UInt_t w, UInt_t h) fDEComboIdx.Set(26); for(i = 0; i < 10; i++) { - sprintf(text,"%d",i+1); + snprintf(text,20,"%d",i+1); fChamberCombo->AddEntry(text,i); } fChamberCombo->Resize(40,20); @@ -415,13 +417,13 @@ void AliMpDEVisu::DrawManuMotif(Bool_t popup) if (AliMpDEManager::GetStationType(fCurrentDetElem) == AliMp::kStation345 ) { - sprintf(command, "%s%d", "PMCI:", (Int_t)fNumberEntry->GetIntNumber()); + snprintf(command, 255, "%s%d", "PMCI:", (Int_t)fNumberEntry->GetIntNumber()); DrawSlat(command, popup); } else { - sprintf(command, "%s%d", "RSMCI:", (Int_t)fNumberEntry->GetIntNumber()); + snprintf(command, 255, "%s%d", "RSMCI:", (Int_t)fNumberEntry->GetIntNumber()); DrawQuadrant(command, popup); -- 2.43.0