Skip to content

Commit

Permalink
Merge pull request akopytov#71 from plusky/strncat_overflow
Browse files Browse the repository at this point in the history
Fix potential buffer overflow
  • Loading branch information
akopytov authored Sep 29, 2016
2 parents 5807d77 + e6fab32 commit b953dab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sysbench/scripting/script_lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,11 @@ lua_State *sb_lua_new_state(const char *scriptname, int thread_id)
/* first location failed - look in DATA_PATH */
char p[PATH_MAX + 1];
strncpy(p, DATA_PATH LUA_DIRSEP, sizeof(p));
strncat(p, scriptname, sizeof(p));
strncat(p, scriptname, sizeof(p)-strlen(p)-1);
if (!strrchr(scriptname, '.'))
{
/* add .lua extension if there isn't one */
strncat(p, ".lua", sizeof(p));
strncat(p, ".lua", sizeof(p)-strlen(p)-1);
}

if (luaL_loadfile(state, p))
Expand Down

0 comments on commit b953dab

Please sign in to comment.