'snprintf()' guarantees null termination of buffer
Thanks @cremno.
This commit is contained in:
		
							parent
							
								
									794e86d0ab
								
							
						
					
					
						commit
						e72bced0f7
					
				
					 4 changed files with 0 additions and 4 deletions
				
			
		| 
						 | 
					@ -236,7 +236,6 @@ void ALStream::openSource(const std::string &filename)
 | 
				
			||||||
		char buf[512];
 | 
							char buf[512];
 | 
				
			||||||
		snprintf(buf, sizeof(buf), "Unable to decode audio stream: %s.%s: %s",
 | 
							snprintf(buf, sizeof(buf), "Unable to decode audio stream: %s.%s: %s",
 | 
				
			||||||
		         filename.c_str(), ext, e.msg.c_str());
 | 
							         filename.c_str(), ext, e.msg.c_str());
 | 
				
			||||||
		buf[sizeof(buf)-1] = '\0';
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Debug() << buf;
 | 
							Debug() << buf;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -611,7 +611,6 @@ static void fontSetEnumCB(void *data, const char *,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	char filename[512];
 | 
						char filename[512];
 | 
				
			||||||
	snprintf(filename, sizeof(filename), "Fonts/%s", fname);
 | 
						snprintf(filename, sizeof(filename), "Fonts/%s", fname);
 | 
				
			||||||
	filename[sizeof(filename)-1] = '\0';
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	PHYSFS_File *handle = PHYSFS_openRead(filename);
 | 
						PHYSFS_File *handle = PHYSFS_openRead(filename);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -533,7 +533,6 @@ struct SettingsMenuPrivate
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			char buf[64];
 | 
								char buf[64];
 | 
				
			||||||
			snprintf(buf, sizeof(buf), "Press key or joystick button for \"%s\"", captureName);
 | 
								snprintf(buf, sizeof(buf), "Press key or joystick button for \"%s\"", captureName);
 | 
				
			||||||
			buf[sizeof(buf)-1] = '\0';
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			drawOff = Vec2i();
 | 
								drawOff = Vec2i();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -213,7 +213,6 @@ SoundBuffer *SoundEmitter::allocateBuffer(const std::string &filename)
 | 
				
			||||||
			char buf[512];
 | 
								char buf[512];
 | 
				
			||||||
			snprintf(buf, sizeof(buf), "Unable to decode sound: %s.%s: %s",
 | 
								snprintf(buf, sizeof(buf), "Unable to decode sound: %s.%s: %s",
 | 
				
			||||||
			         filename.c_str(), ext, Sound_GetError());
 | 
								         filename.c_str(), ext, Sound_GetError());
 | 
				
			||||||
			buf[sizeof(buf)-1] = '\0';
 | 
					 | 
				
			||||||
			Debug() << buf;
 | 
								Debug() << buf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			return 0;
 | 
								return 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue