mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-31 09:21:09 +02:00
src/gui/lua/lua_filehelpers.cpp fix possible segfault if string argument is not a string (nil)
Origin commit data
------------------
Branch: ni/coolstream
Commit: d3ae00d688
Author: Jacek Jendrzej <overx300@gmail.com>
Date: 2016-09-07 (Wed, 07 Sep 2016)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -93,26 +93,23 @@ int CLuaInstFileHelpers::FileHelpersCp(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lua_isstring(L, 2)) {
|
if (!lua_isstring(L, 2) || !lua_isstring(L, 3)) {
|
||||||
printf("luascript cp: argument 1 is not a string.\n");
|
printf("%s: argument 1 or 2 is not a string.\n",__func__);
|
||||||
lua_pushboolean(L, false);
|
lua_pushboolean(L, false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
const char *from = "";
|
const char *from = luaL_checkstring(L, 2);
|
||||||
from = luaL_checkstring(L, 2);
|
const char *to = luaL_checkstring(L, 3);
|
||||||
|
|
||||||
if (!lua_isstring(L, 3)) {
|
|
||||||
printf("luascript cp: argument 2 is not a string.\n");
|
|
||||||
lua_pushboolean(L, false);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
const char *to = "";
|
|
||||||
to = luaL_checkstring(L, 3);
|
|
||||||
|
|
||||||
const char *flags = "";
|
const char *flags = "";
|
||||||
if (numargs > min_numargs)
|
if (numargs > min_numargs){
|
||||||
|
if (!lua_isstring(L, 4)) {
|
||||||
|
printf("%s: argument 3 is not a string.\n",__func__);
|
||||||
|
lua_pushboolean(L, false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
flags = luaL_checkstring(L, 4);
|
flags = luaL_checkstring(L, 4);
|
||||||
|
}
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
CFileHelpers fh;
|
CFileHelpers fh;
|
||||||
fh.setConsoleQuiet(true);
|
fh.setConsoleQuiet(true);
|
||||||
@@ -143,9 +140,12 @@ int CLuaInstFileHelpers::FileHelpersChmod(lua_State *L)
|
|||||||
lua_pushboolean(L, false);
|
lua_pushboolean(L, false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (!lua_isstring(L, 2)) {
|
||||||
const char *file = "";
|
printf("%s: argument 1 is not a string.\n",__func__);
|
||||||
file = luaL_checkstring(L, 2);
|
lua_pushboolean(L, false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
const char *file = luaL_checkstring(L, 2);
|
||||||
|
|
||||||
int mode_i = luaL_checkint(L, 3);
|
int mode_i = luaL_checkint(L, 3);
|
||||||
/* Hack for convert lua number to octal */
|
/* Hack for convert lua number to octal */
|
||||||
@@ -180,9 +180,12 @@ int CLuaInstFileHelpers::FileHelpersTouch(lua_State *L)
|
|||||||
lua_pushboolean(L, false);
|
lua_pushboolean(L, false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (!lua_isstring(L, 2)) {
|
||||||
const char *file = "";
|
printf("%s: argument 1 is not a string.\n",__func__);
|
||||||
file = luaL_checkstring(L, 2);
|
lua_pushboolean(L, false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
const char *file = luaL_checkstring(L, 2);
|
||||||
|
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
lua_Debug ar;
|
lua_Debug ar;
|
||||||
@@ -242,9 +245,12 @@ int CLuaInstFileHelpers::FileHelpersRmdir(lua_State *L)
|
|||||||
lua_pushboolean(L, false);
|
lua_pushboolean(L, false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (!lua_isstring(L, 2)) {
|
||||||
const char *dir = "";
|
printf("%s: argument 1 is not a string.\n",__func__);
|
||||||
dir = luaL_checkstring(L, 2);
|
lua_pushboolean(L, false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
const char *dir = luaL_checkstring(L, 2);
|
||||||
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
CFileHelpers* fh = CFileHelpers::getInstance();
|
CFileHelpers* fh = CFileHelpers::getInstance();
|
||||||
@@ -276,9 +282,12 @@ int CLuaInstFileHelpers::FileHelpersMkdir(lua_State *L)
|
|||||||
lua_pushboolean(L, false);
|
lua_pushboolean(L, false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (!lua_isstring(L, 2)) {
|
||||||
const char *dir = "";
|
printf("%s: argument 1 is not a string.\n",__func__);
|
||||||
dir = luaL_checkstring(L, 2);
|
lua_pushboolean(L, false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
const char *dir = luaL_checkstring(L, 2);
|
||||||
|
|
||||||
mode_t mode = 0755;
|
mode_t mode = 0755;
|
||||||
if (numargs > min_numargs) {
|
if (numargs > min_numargs) {
|
||||||
@@ -319,9 +328,12 @@ int CLuaInstFileHelpers::FileHelpersReadlink(lua_State *L)
|
|||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (!lua_isstring(L, 2)) {
|
||||||
const char *link = "";
|
printf("%s: argument 1 is not a string.\n",__func__);
|
||||||
link = luaL_checkstring(L, 2);
|
lua_pushboolean(L, false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
const char *link = luaL_checkstring(L, 2);
|
||||||
|
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
memset(buf, '\0', sizeof(buf));
|
memset(buf, '\0', sizeof(buf));
|
||||||
@@ -353,16 +365,23 @@ int CLuaInstFileHelpers::FileHelpersLn(lua_State *L)
|
|||||||
lua_pushboolean(L, false);
|
lua_pushboolean(L, false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (!lua_isstring(L, 2) || !lua_isstring(L, 3)) {
|
||||||
const char *src = "";
|
printf("%s: argument 1 or 2 is not a string.\n",__func__);
|
||||||
src = luaL_checkstring(L, 2);
|
lua_pushboolean(L, false);
|
||||||
const char *link = "";
|
return 1;
|
||||||
link = luaL_checkstring(L, 3);
|
}
|
||||||
|
const char *src = luaL_checkstring(L, 2);
|
||||||
|
const char *link = luaL_checkstring(L, 3);
|
||||||
|
|
||||||
const char *flags = "";
|
const char *flags = "";
|
||||||
if (numargs > min_numargs)
|
if (numargs > min_numargs){
|
||||||
|
if (!lua_isstring(L, 4)) {
|
||||||
|
printf("%s: argument 3 is not a string.\n",__func__);
|
||||||
|
lua_pushboolean(L, false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
flags = luaL_checkstring(L, 4);
|
flags = luaL_checkstring(L, 4);
|
||||||
|
}
|
||||||
bool symlnk = (strchr(flags, 's') != NULL);
|
bool symlnk = (strchr(flags, 's') != NULL);
|
||||||
bool force = (strchr(flags, 'f') != NULL);
|
bool force = (strchr(flags, 'f') != NULL);
|
||||||
lua_Debug ar;
|
lua_Debug ar;
|
||||||
@@ -413,15 +432,18 @@ int CLuaInstFileHelpers::FileHelpersExist(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!lua_isstring(L, 2) || !lua_isstring(L, 3)) {
|
||||||
|
printf("%s: argument 1 or 2 is not a string.\n",__func__);
|
||||||
|
lua_pushboolean(L, false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
bool err = false;
|
bool err = false;
|
||||||
int errLine = 0;
|
int errLine = 0;
|
||||||
std::string errMsg = "";
|
std::string errMsg = "";
|
||||||
|
|
||||||
const char *file = "";
|
const char *file = luaL_checkstring(L, 2);
|
||||||
file = luaL_checkstring(L, 2);
|
const char *flag = luaL_checkstring(L, 3);
|
||||||
const char *flag = "";
|
|
||||||
flag = luaL_checkstring(L, 3);
|
|
||||||
|
|
||||||
if (file_exists(file)) {
|
if (file_exists(file)) {
|
||||||
struct stat FileInfo;
|
struct stat FileInfo;
|
||||||
|
Reference in New Issue
Block a user