Patch more dangerous strcat buffers

feature/pre-code-move
kaetemi 5 years ago committed by Jan Boon
parent ef6f2ea34b
commit 281a599036

@ -1,6 +1,9 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This source file has been modified by the following contributors:
// Copyright (C) 2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
//
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the

@ -2,7 +2,7 @@
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This source file has been modified by the following contributors: // This source file has been modified by the following contributors:
// Copyright (C) 2015 Jan BOON (Kaetemi) <jan.boon@kaetemi.be> // Copyright (C) 2015-2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
@ -19,6 +19,8 @@
#include "stdpacs.h" #include "stdpacs.h"
#include <sstream>
#include "nel/misc/plane.h" #include "nel/misc/plane.h"
#include "nel/pacs/local_retriever.h" #include "nel/pacs/local_retriever.h"
@ -269,15 +271,16 @@ void NLPACS::CLocalRetriever::dumpSurface(uint surf, const CVector &vect) const
{ {
const CRetrievableSurface::TLoop &loop = surface._Loops[i]; const CRetrievableSurface::TLoop &loop = surface._Loops[i];
nlinfo("-- loop %d: %d chains length=%.2f", i, loop.size(), loop.Length); nlinfo("-- loop %d: %d chains length=%.2f", i, loop.size(), loop.Length);
static char wbuffer[256]; char wbuffer[256];
static char buffer[10240]; stringstream ss;
sprintf(buffer, " chains:"); sprintf(wbuffer, " chains:");
ss << wbuffer;
for (j=0; j<loop.size(); ++j) for (j=0; j<loop.size(); ++j)
{ {
sprintf(wbuffer, " %d[%d]", loop[j], surface._Chains[loop[j]].Chain); sprintf(wbuffer, " %d[%d]", loop[j], surface._Chains[loop[j]].Chain);
strcat(buffer, wbuffer); ss << wbuffer;
} }
nlinfo("%s", buffer); nlinfo("%s", ss.str().c_str());
} }
} }

@ -1,6 +1,9 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This source file has been modified by the following contributors:
// Copyright (C) 2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
//
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
@ -18,6 +21,10 @@
#include "../zone_lib/zone_utility.h" #include "../zone_lib/zone_utility.h"
#include <iostream> #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#include "nel/misc/file.h" #include "nel/misc/file.h"
#include "nel/misc/common.h" #include "nel/misc/common.h"
@ -27,8 +34,6 @@
#include "nel/3d/zone_smoother.h" #include "nel/3d/zone_smoother.h"
#include "nel/3d/zone_tgt_smoother.h" #include "nel/3d/zone_tgt_smoother.h"
#include "nel/3d/zone_corner_smoother.h" #include "nel/3d/zone_corner_smoother.h"
#include <vector>
#include <set>
using namespace NL3D; using namespace NL3D;
@ -579,7 +584,8 @@ void weldZones(const char *center)
if (adjZonePatchs[patchIndex].BindEdges[edgeIndex].NPatchs!=0) if (adjZonePatchs[patchIndex].BindEdges[edgeIndex].NPatchs!=0)
{ {
// Build an error message // Build an error message
char error[8000]; char buf[2048];
stringstream sserror;
// Zone name // Zone name
string nameCenter, nameAdj; string nameCenter, nameAdj;
@ -587,10 +593,11 @@ void weldZones(const char *center)
getZoneNameByCoord (adjZonesId[i]&0xff, (adjZonesId[i]>>8)+1, nameAdj); getZoneNameByCoord (adjZonesId[i]&0xff, (adjZonesId[i]>>8)+1, nameAdj);
// Main message // Main message
smprintf (error, 2048, smprintf(buf, 2048,
"Bind Error: try to bind the patch n %d in zone n %s with patch n %d in zone %s\n" "Bind Error: try to bind the patch n %d in zone n %s with patch n %d in zone %s\n"
"This patch is already binded with the following patches : ", ptch+1, nameAdj.c_str(), "This patch is already binded with the following patches : ", ptch+1, nameAdj.c_str(),
patchIndex+1, nameCenter.c_str() ); patchIndex+1, nameCenter.c_str() );
sserror << buf;
// Sub message // Sub message
for (uint i=0; i<adjZonePatchs[patchIndex].BindEdges[edgeIndex].NPatchs; i++) for (uint i=0; i<adjZonePatchs[patchIndex].BindEdges[edgeIndex].NPatchs; i++)
@ -599,16 +606,15 @@ void weldZones(const char *center)
bool last=(i==(uint)(adjZonePatchs[patchIndex].BindEdges[edgeIndex].NPatchs-1)); bool last=(i==(uint)(adjZonePatchs[patchIndex].BindEdges[edgeIndex].NPatchs-1));
// Sub message // Sub message
char subMessage[512]; smprintf(buf, 2048,
smprintf ( subMessage, 512,
"patch n %d%s", adjZonePatchs[patchIndex].BindEdges[edgeIndex].Next[i]+1, last?"\n":","); "patch n %d%s", adjZonePatchs[patchIndex].BindEdges[edgeIndex].Next[i]+1, last?"\n":",");
// Concat the message // Concat the message
strcat (error, subMessage); sserror << buf;
} }
// Add an error message // Add an error message
errorMessage.push_back (error); errorMessage.push_back(sserror.str());
} }
else else
{ {

@ -1,6 +1,9 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This source file has been modified by the following contributors:
// Copyright (C) 2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
//
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the

@ -1,6 +1,9 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/> // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This source file has been modified by the following contributors:
// Copyright (C) 2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
//
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
@ -16,6 +19,8 @@
#include "stdafx.h" #include "stdafx.h"
#include <sstream>
#include "editor_primitive.h" #include "editor_primitive.h"
#include "generate_primitive.h" #include "generate_primitive.h"
#include "world_editor.h" #include "world_editor.h"
@ -364,15 +369,12 @@ bool CGeneratePrimitive::generate (std::vector< std::vector<IPrimitive*> > &dest
if (!_FileNotFound.empty()) if (!_FileNotFound.empty())
{ {
// Continue ? // Continue ?
char message[2048]; stringstream ssmessage;
message[0] = 0;
for (uint i = 0; i < _FileNotFound.size(); i++) for (uint i = 0; i < _FileNotFound.size(); i++)
{ {
strcat (message, _FileNotFound[i].c_str ()); ssmessage << _FileNotFound[i] << "\n";
strcat (message, "\n");
} }
if (!theApp.yesNoMessage("Can't load some files:\n%s\nContinue ?", ssmessage.str()))
if (!theApp.yesNoMessage ("Can't load some files:\n%s\nContinue ?", message))
{ {
return false; return false;
} }

Loading…
Cancel
Save