Skip to content

Commit

Permalink
ZVISION: Silence Cppcheck warnings about buffer overflow
Browse files Browse the repository at this point in the history
I don't know if it's the buffer sizes or the format strings that
should be fixed, but increasing the buffer size seems like the safer
thing to do in cases of doubt.
  • Loading branch information
Torbjörn Andersson committed Aug 6, 2014
1 parent ea2ee4a commit e8cb2a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions engines/zvision/scripting/actions.cpp
Expand Up @@ -155,7 +155,7 @@ bool ActionEnableControl::execute(ZVision *engine) {

ActionMusic::ActionMusic(const Common::String &line) : _volume(255) {
uint type;
char fileNameBuffer[25];
char fileNameBuffer[26];
uint loop;
uint volume = 255;

Expand Down Expand Up @@ -211,7 +211,7 @@ bool ActionMusic::execute(ZVision *engine) {
//////////////////////////////////////////////////////////////////////////////

ActionPreloadAnimation::ActionPreloadAnimation(const Common::String &line) {
char fileName[25];
char fileName[26];

// The two %*u are always 0 and dont seem to have a use
sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%25s %*u %*u %u %u)", &_key, fileName, &_mask, &_framerate);
Expand All @@ -238,7 +238,7 @@ bool ActionPreloadAnimation::execute(ZVision *engine) {
//////////////////////////////////////////////////////////////////////////////

ActionPlayAnimation::ActionPlayAnimation(const Common::String &line) {
char fileName[25];
char fileName[26];

// The two %*u are always 0 and dont seem to have a use
sscanf(line.c_str(),
Expand Down Expand Up @@ -312,7 +312,7 @@ bool ActionRandom::execute(ZVision *engine) {
//////////////////////////////////////////////////////////////////////////////

ActionSetPartialScreen::ActionSetPartialScreen(const Common::String &line) {
char fileName[25];
char fileName[26];
uint color;

sscanf(line.c_str(), "%*[^(](%u %u %25s %*u %u)", &_x, &_y, fileName, &color);
Expand Down Expand Up @@ -342,7 +342,7 @@ bool ActionSetPartialScreen::execute(ZVision *engine) {
//////////////////////////////////////////////////////////////////////////////

ActionSetScreen::ActionSetScreen(const Common::String &line) {
char fileName[25];
char fileName[26];
sscanf(line.c_str(), "%*[^(](%25[^)])", fileName);

_fileName = Common::String(fileName);
Expand All @@ -360,7 +360,7 @@ bool ActionSetScreen::execute(ZVision *engine) {
//////////////////////////////////////////////////////////////////////////////

ActionStreamVideo::ActionStreamVideo(const Common::String &line) {
char fileName[25];
char fileName[26];
uint skippable;

sscanf(line.c_str(), "%*[^(](%25s %u %u %u %u %u %u)", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skippable);
Expand Down
2 changes: 1 addition & 1 deletion engines/zvision/scripting/controls/input_control.cpp
Expand Up @@ -75,7 +75,7 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre
} else if (line.matchString("*next_tabstop*", true)) {
sscanf(line.c_str(), "%*[^(](%u)", &_nextTabstop);
} else if (line.matchString("*cursor_animation*", true)) {
char fileName[25];
char fileName[26];

sscanf(line.c_str(), "%*[^(](%25s %*u)", fileName);

Expand Down

0 comments on commit e8cb2a3

Please sign in to comment.