//read texture from cache
std::string name = deSerializeString(is);
std::string sha1_texture = deSerializeString(is);
+
+ // if name contains illegal characters, ignore the texture
+ if(!string_allowed(name, TEXTURENAME_ALLOWED_CHARS)){
+ errorstream<<"Client: ignoring illegal texture name "
+ <<"sent by server: \""<<name<<"\""<<std::endl;
+ continue;
+ }
std::string tpath = getTextureCacheDir() + DIR_DELIM + name;
// Read data
for each texture {
u16 length of name
string name
- u16 length of path
- string path
}
*/
std::ostringstream os(std::ios_base::binary);
for(int i=0; i<num_textures; i++){
std::string name = deSerializeString(is);
std::string data = deSerializeLongString(is);
+
+ // if name contains illegal characters, ignore the texture
+ if(!string_allowed(name, TEXTURENAME_ALLOWED_CHARS)){
+ errorstream<<"Client: ignoring illegal texture name "
+ <<"sent by server: \""<<name<<"\""<<std::endl;
+ continue;
+ }
+
// Silly irrlicht's const-incorrectness
Buffer<char> data_rw(data.c_str(), data.size());
// Create an irrlicht memory file
if(dirlist[j].dir) // Ignode dirs
continue;
std::string tname = dirlist[j].name;
+ // if name contains illegal characters, ignore the texture
+ if(!string_allowed(tname, TEXTURENAME_ALLOWED_CHARS)){
+ errorstream<<"Server: ignoring illegal texture name: \""
+ <<tname<<"\""<<std::endl;
+ continue;
+ }
std::string tpath = texturepath + DIR_DELIM + tname;
// Read data
std::ifstream fis(tpath.c_str(), std::ios_base::binary);
<<tname<<"\""<<std::endl;
continue;
}
+ if(tmp_os.str().length() == 0){
+ errorstream<<"Server::PrepareTextures(): Empty file \""
+ <<tpath<<"\""<<std::endl;
+ continue;
+ }
SHA1 sha1;
sha1.addBytes(tmp_os.str().c_str(), tmp_os.str().length());
void Server::SendTextureAnnouncement(u16 peer_id){
DSTACK(__FUNCTION_NAME);
- infostream<<"Server::SendTextureAnnouncement(): Calculate sha1 sums of textures and send to client"<<std::endl;
+ infostream<<"Server::SendTextureAnnouncement()"<<std::endl;
core::list<SendableTextureAnnouncement> texture_announcements;
u32 texture_size_bunch_total = 0;
for(core::list<TextureRequest>::Iterator i = tosend.begin(); i != tosend.end(); i++) {
+ if(m_Textures.find(i->name) == m_Textures.end()){
+ errorstream<<"Server::SendTexturesRequested(): Client asked for "
+ <<"unknown texture \""<<(i->name)<<"\""<<std::endl;
+ continue;
+ }
//TODO get path + name
std::string tpath = m_Textures[(*i).name].path;