jenkins-bot has submitted this change and it was merged.
Change subject: Remove line-ending whitespace
......................................................................
Remove line-ending whitespace
I'm tired of my editor flagging this for me constantly.
Change-Id: Ic8b601ac305cc7abe60982d0d7fe1b4466d6536f
---
M alloc.c
M data_conversion.c
M library.c
M luasandbox.c
M luasandbox_types.h
M php_luasandbox.h
M timer.c
7 files changed, 143 insertions(+), 143 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/alloc.c b/alloc.c
index 373810c..5585c5d 100644
--- a/alloc.c
+++ b/alloc.c
@@ -16,7 +16,7 @@
#define LUASANDBOX_LJ_64
#endif
-static inline int luasandbox_update_memory_accounting(php_luasandbox_alloc *
obj,
+static inline int luasandbox_update_memory_accounting(php_luasandbox_alloc *
obj,
size_t osize, size_t nsize, int in_lua);
#ifdef LUASANDBOX_LJ_64
static void *luasandbox_passthru_alloc(void *ud, void *ptr, size_t osize,
size_t nsize);
@@ -42,9 +42,9 @@
void luasandbox_alloc_delete_state(php_luasandbox_alloc * alloc, lua_State * L)
{
- // In 64-bit LuaJIT mode, restore the old allocator before calling
- // lua_close() because lua_close() actually checks that the value of
the
- // function pointer is unchanged before destroying the underlying
+ // In 64-bit LuaJIT mode, restore the old allocator before calling
+ // lua_close() because lua_close() actually checks that the value of the
+ // function pointer is unchanged before destroying the underlying
// allocator. If the allocator has been changed, the mmap is not freed.
#ifdef LUASANDBOX_LJ_64
lua_setallocf(L, alloc->old_alloc, alloc->old_alloc_ud);
@@ -59,7 +59,7 @@
* Update memory usage statistics for the given memory allocation request.
* Returns 1 if the allocation should be allowed, 0 if it should fail.
*/
-static inline int luasandbox_update_memory_accounting(php_luasandbox_alloc *
alloc,
+static inline int luasandbox_update_memory_accounting(php_luasandbox_alloc *
alloc,
size_t osize, size_t nsize, int in_lua)
{
// Allow some extra memory overhead for non-in_lua allocations to avoid
@@ -90,10 +90,10 @@
/** {{{ luasandbox_php_alloc
*
* The Lua allocator function. Use PHP's request-local allocator as a backend.
- * Account for memory usage and deny the allocation request if the amount
+ * Account for memory usage and deny the allocation request if the amount
* allocated is above the user-specified limit.
*/
-static void *luasandbox_php_alloc(void *ud, void *ptr, size_t osize, size_t
nsize)
+static void *luasandbox_php_alloc(void *ud, void *ptr, size_t osize, size_t
nsize)
{
php_luasandbox_obj * obj = (php_luasandbox_obj*)ud;
void * nptr;
@@ -122,12 +122,12 @@
#ifdef LUASANDBOX_LJ_64
/** {{{ luasandbox_passthru_alloc
*
- * A Lua allocator function for use with LuaJIT on a 64-bit platform. Pass
+ * A Lua allocator function for use with LuaJIT on a 64-bit platform. Pass
* allocation requests through to the standard allocator, which is customised
- * on this platform to always return memory from the lower 2GB of address
+ * on this platform to always return memory from the lower 2GB of address
* space.
*/
-static void *luasandbox_passthru_alloc(void *ud, void *ptr, size_t osize,
size_t nsize)
+static void *luasandbox_passthru_alloc(void *ud, void *ptr, size_t osize,
size_t nsize)
{
php_luasandbox_obj * obj = (php_luasandbox_obj*)ud;
if (!luasandbox_update_memory_accounting(&obj->alloc, osize, nsize,
obj->in_lua)) {
diff --git a/data_conversion.c b/data_conversion.c
index e32f330..0c0ccad 100644
--- a/data_conversion.c
+++ b/data_conversion.c
@@ -35,7 +35,7 @@
extern zend_class_entry *luasandboxruntimeerror_ce;
/**
- * An int, the address of which is used as a fatal error marker. The value is
+ * An int, the address of which is used as a fatal error marker. The value is
* not used.
*/
int luasandbox_fatal_error_marker = 0;
@@ -87,19 +87,19 @@
case IS_OBJECT: {
TSRMLS_FETCH();
zend_class_entry * objce;
-
+
objce = Z_OBJCE_P(z);
if (instanceof_function(objce, luasandboxfunction_ce
TSRMLS_CC)) {
php_luasandboxfunction_obj * func_obj;
-
+
func_obj = (php_luasandboxfunction_obj
*)zend_object_store_get_object(z TSRMLS_CC);
-
+
lua_getfield(L, LUA_REGISTRYINDEX,
"php_luasandbox_chunks");
lua_rawgeti(L, -1, func_obj->index);
lua_remove(L, -2);
break;
}
-
+
if (!luasandbox_push_hashtable(L, Z_OBJPROP_P(z))) {
return 0;
}
@@ -139,8 +139,8 @@
/** {{{ luasandbox_push_zval_userdata
*
- * Push a full userdata on to the stack, which stores a zval* in its block.
- * Increment its reference count and set its metatable so that it will be
freed
+ * Push a full userdata on to the stack, which stores a zval* in its block.
+ * Increment its reference count and set its metatable so that it will be freed
* at the appropriate time.
*/
void luasandbox_push_zval_userdata(lua_State * L, zval * z)
@@ -157,14 +157,14 @@
/** {{{ luasandbox_push_hashtable
*
- * Helper function for luasandbox_push_zval. Create a new table on the top of
- * the stack and add the zvals in the HashTable to it.
+ * Helper function for luasandbox_push_zval. Create a new table on the top of
+ * the stack and add the zvals in the HashTable to it.
*/
static int luasandbox_push_hashtable(lua_State * L, HashTable * ht)
{
HashPosition p;
- // Recursion requires an arbitrary amount of stack space so we have to
+ // Recursion requires an arbitrary amount of stack space so we have to
// check the stack.
luaL_checkstack(L, 10, "converting PHP array to Lua");
@@ -223,8 +223,8 @@
* @param index The stack index to the input value
* @param sandbox_zval A zval poiting to a valid LuaSandbox object which will
be
* used for the parent object of any LuaSandboxFunction objects created.
- * @param recursionGuard A hashtable for keeping track of tables that have
been
- * processed, to allow infinite recursion to be avoided. External callers
+ * @param recursionGuard A hashtable for keeping track of tables that have been
+ * processed, to allow infinite recursion to be avoided. External callers
* should set this to NULL.
* @return int 0 (and a PHP exception) on failure
*/
@@ -252,7 +252,7 @@
|| labs(i) < (1L << DBL_MANT_DIG))
{
ZVAL_LONG(z, i);
- } else {
+ } else {
ZVAL_DOUBLE(z, d);
}
} else {
@@ -335,7 +335,7 @@
if (index < 0) {
index += lua_gettop(L) + 1;
}
-
+
// Get the chunks table
lua_getfield(L, LUA_REGISTRYINDEX,
"php_luasandbox_chunks");
@@ -543,7 +543,7 @@
/** {{{ luasandbox_wrap_fatal
*
- * Pop a value off the top of the stack, and push a fatal error wrapper
+ * Pop a value off the top of the stack, and push a fatal error wrapper
* containing the value.
*/
void luasandbox_wrap_fatal(lua_State * L)
@@ -552,7 +552,7 @@
lua_createtable(L, 0, 2);
lua_pushlightuserdata(L, &luasandbox_fatal_error_marker);
lua_rawseti(L, -2, 1);
-
+
// Swap the table with the input value, so that the value is on the top,
// then put the value in the table as element 2
lua_insert(L, -2);
@@ -562,7 +562,7 @@
/** {{{ luasandbox_is_fatal
*
- * Check if the value at the given stack index is a fatal error wrapper
+ * Check if the value at the given stack index is a fatal error wrapper
* created by luasandbox_wrap_fatal(). Return 1 if it is, 0 otherwise.
*/
int luasandbox_is_fatal(lua_State * L, int index)
@@ -598,13 +598,13 @@
/** {{{
*
- * If the value at the given stack index is a fatal error wrapper, convert
- * the error object it wraps to a string. If the value is anything else,
+ * If the value at the given stack index is a fatal error wrapper, convert
+ * the error object it wraps to a string. If the value is anything else,
* convert it directly to a string. If the error object is not convertible
* to a string, return "unknown error".
*
- * This calls lua_tolstring() and will corrupt the value on the stack as
- * described in that function's documentation. The string is valid until the
+ * This calls lua_tolstring() and will corrupt the value on the stack as
+ * described in that function's documentation. The string is valid until the
* Lua value is destroyed.
*/
const char * luasandbox_error_to_string(lua_State * L, int index)
@@ -644,7 +644,7 @@
lua_createtable(L, 0, 3);
lua_pushlightuserdata(L, &luasandbox_trace_error_marker);
lua_rawseti(L, -2, 1);
-
+
// Swap the table with the input value, so that the value is on the top,
// then put the value in the table as element 2
lua_insert(L, -2);
@@ -653,7 +653,7 @@
// Put the backtrace in element 3
luasandbox_push_structured_trace(L, 1);
lua_rawseti(L, -2, 3);
-
+
return 1;
}
/* }}} */
diff --git a/library.c b/library.c
index 7ab7187..0734b88 100644
--- a/library.c
+++ b/library.c
@@ -1,6 +1,6 @@
/**
- * This file holds the library of functions which are written in C and exposed
- * to Lua code, and the code which manages registration of both the custom
+ * This file holds the library of functions which are written in C and exposed
+ * to Lua code, and the code which manages registration of both the custom
* library and the parts of the standard Lua library which we allow.
*/
@@ -37,14 +37,14 @@
/**
* Allowed global variables. Omissions are:
* * pcall, xpcall: We have our own versions which don't allow interception
of
- * timeout etc. errors.
+ * timeout etc. errors.
* * loadfile: insecure.
- * * load, loadstring: Probably creates a protected environment so has
- * the same problem as pcall. Also omitting these makes analysis of the
+ * * load, loadstring: Probably creates a protected environment so has
+ * the same problem as pcall. Also omitting these makes analysis of the
* code for runtime etc. feasible.
* * print: Not compatible with a sandbox environment
- * * tostring: Provides addresses of tables and functions, which provides an
- * easy ASLR workaround or heap address discovery mechanism for a memory
+ * * tostring: Provides addresses of tables and functions, which provides an
+ * easy ASLR workaround or heap address discovery mechanism for a memory
* corruption exploit. We have our own version.
* * Any new or undocumented functions like newproxy.
* * package: cpath, loadlib etc. are insecure.
@@ -128,7 +128,7 @@
luasandbox_lib_filter_table(L, luasandbox_allowed_debug_members);
lua_setglobal(L, "debug");
- // Remove any globals that aren't in a whitelist. This is mostly to
remove
+ // Remove any globals that aren't in a whitelist. This is mostly to
remove
// unsafe functions from the base library.
lua_pushnil(L);
while (lua_next(L, LUA_GLOBALSINDEX) != 0) {
@@ -140,8 +140,8 @@
continue;
}
key = lua_tolstring(L, -1, &key_len);
- if
(zend_hash_find(luasandbox_lib_get_allowed_globals(TSRMLS_C),
- (char*)key, key_len + 1, &data) == FAILURE)
+ if (zend_hash_find(luasandbox_lib_get_allowed_globals(TSRMLS_C),
+ (char*)key, key_len + 1, &data) == FAILURE)
{
// Not allowed, delete it
lua_pushnil(L);
@@ -193,7 +193,7 @@
/* }}} */
/** {{{ luasandbox_lib_filter_table
- *
+ *
* Make a copy of the table at the top of the stack, and remove any members
* from it that aren't in the given whitelist.
*/
@@ -238,7 +238,7 @@
ALLOC_HASHTABLE(LUASANDBOX_G(allowed_globals));
zend_hash_init(LUASANDBOX_G(allowed_globals), n, NULL, NULL, 0);
for (i = 0; luasandbox_allowed_globals[i]; i++) {
- zend_hash_update(LUASANDBOX_G(allowed_globals),
+ zend_hash_update(LUASANDBOX_G(allowed_globals),
luasandbox_allowed_globals[i],
strlen(luasandbox_allowed_globals[i]) + 1,
(void*)"", 1, NULL);
}
@@ -328,8 +328,8 @@
/** {{{ luasandbox_lib_rethrow_fatal
*
- * If the error on the top of the stack with the error return code given as a
- * parameter is a fatal, rethrow the error. If the error is rethrown, the
+ * If the error on the top of the stack with the error return code given as a
+ * parameter is a fatal, rethrow the error. If the error is rethrown, the
* function does not return.
*/
static void luasandbox_lib_rethrow_fatal(lua_State * L, int status)
@@ -346,7 +346,7 @@
break;
case LUA_ERRMEM:
case LUA_ERRERR:
- // Lua doesn't provide a public API for rethrowing
these, so we
+ // Lua doesn't provide a public API for rethrowing
these, so we
// have to convert them to our own fatal error type
if (!luasandbox_is_fatal(L, -1)) {
luasandbox_wrap_fatal(L);
@@ -366,11 +366,11 @@
int status;
luaL_checkany(L, 1);
- // This function is only called from luaG_errormsg(), which will later
- // unconditionally set the status code to LUA_ERRRUN, so we can assume
+ // This function is only called from luaG_errormsg(), which will later
+ // unconditionally set the status code to LUA_ERRRUN, so we can assume
// that the error type is equivalent to LUA_ERRRUN.
if (luasandbox_is_fatal(L, 1)) {
- // Just return to whatever called lua_pcall(), don't call the
user
+ // Just return to whatever called lua_pcall(), don't call the
user
// function
return lua_gettop(L);
}
@@ -414,8 +414,8 @@
int status;
luaL_checkany(L, 2);
lua_settop(L, 2);
-
- // We wrap the error function in a C closure. The error function
already
+
+ // We wrap the error function in a C closure. The error function already
// happens to be at the top of the stack, so we don't need to push it
before
// calling lua_pushcfunction to make it an upvalue
lua_pushcclosure(L, luasandbox_lib_error_wrapper, 1);
@@ -432,7 +432,7 @@
/** {{{ luasandbox_os_clock
*
* Implementation of os.clock() which uses our high-resolution usage timer,
- * if available, to provide an accurate measure of Lua CPU usage since a
+ * if available, to provide an accurate measure of Lua CPU usage since a
* particular LuaSandbox object was created.
*/
static int luasandbox_os_clock(lua_State * L)
diff --git a/luasandbox.c b/luasandbox.c
index 07ef6b1..53e273a 100644
--- a/luasandbox.c
+++ b/luasandbox.c
@@ -39,12 +39,12 @@
static int luasandbox_panic(lua_State * L);
static lua_State * luasandbox_state_from_zval(zval * this_ptr TSRMLS_DC);
static void luasandbox_load_helper(int binary, INTERNAL_FUNCTION_PARAMETERS);
-static int luasandbox_find_field(lua_State * L, int index,
+static int luasandbox_find_field(lua_State * L, int index,
char * spec, int specLength);
static void luasandbox_set_timespec(struct timespec * dest, double source);
-static int luasandbox_function_init(zval * this_ptr,
php_luasandboxfunction_obj ** pfunc,
+static int luasandbox_function_init(zval * this_ptr,
php_luasandboxfunction_obj ** pfunc,
lua_State ** pstate, php_luasandbox_obj ** psandbox TSRMLS_DC);
-static void luasandbox_call_helper(lua_State * L, zval * sandbox_zval,
+static void luasandbox_call_helper(lua_State * L, zval * sandbox_zval,
php_luasandbox_obj * sandbox,
zval *** args, zend_uint numArgs, zval * return_value TSRMLS_DC);
static void luasandbox_handle_error(php_luasandbox_obj * sandbox, int status
TSRMLS_DC);
@@ -175,7 +175,7 @@
};
const zend_function_entry luasandboxfunction_methods[] = {
- PHP_ME(LuaSandboxFunction, __construct,
arginfo_luasandboxfunction___construct,
+ PHP_ME(LuaSandboxFunction, __construct,
arginfo_luasandboxfunction___construct,
ZEND_ACC_PRIVATE | ZEND_ACC_FINAL)
PHP_ME(LuaSandboxFunction, call, arginfo_luasandboxfunction_call, 0)
PHP_ME(LuaSandboxFunction, dump, arginfo_luasandboxfunction_dump, 0)
@@ -218,7 +218,7 @@
*/
PHP_MINIT_FUNCTION(luasandbox)
{
- /* If you have INI entries, uncomment these lines
+ /* If you have INI entries, uncomment these lines
REGISTER_INI_ENTRIES();
*/
@@ -236,7 +236,7 @@
INIT_CLASS_ENTRY(ce, "LuaSandboxError", luasandbox_empty_methods);
luasandboxerror_ce = zend_register_internal_class_ex(
&ce, zend_exception_get_default(TSRMLS_C), NULL
TSRMLS_CC);
- zend_declare_class_constant_long(luasandboxerror_ce,
+ zend_declare_class_constant_long(luasandboxerror_ce,
"RUN", sizeof("RUN")-1, LUA_ERRRUN TSRMLS_CC);
zend_declare_class_constant_long(luasandboxerror_ce,
"SYNTAX", sizeof("SYNTAX")-1, LUA_ERRSYNTAX TSRMLS_CC);
@@ -367,8 +367,8 @@
// Put the object into the store
retval.handle = zend_objects_store_put(
sandbox,
- (zend_objects_store_dtor_t)zend_objects_destroy_object,
- (zend_objects_free_object_storage_t)luasandbox_free_storage,
+ (zend_objects_store_dtor_t)zend_objects_destroy_object,
+ (zend_objects_free_object_storage_t)luasandbox_free_storage,
NULL TSRMLS_CC);
retval.handlers = zend_get_std_object_handlers();
LUASANDBOX_G(active_count)++;
@@ -376,12 +376,12 @@
}
/* }}} */
-/** {{{ luasandbox_newstate
+/** {{{ luasandbox_newstate
*
* Create a new lua_State which is suitable for running sandboxed scripts in.
* Initialise libraries and any necessary registry entries.
*/
-static lua_State * luasandbox_newstate(php_luasandbox_obj * intern TSRMLS_DC)
+static lua_State * luasandbox_newstate(php_luasandbox_obj * intern TSRMLS_DC)
{
lua_State * L = luasandbox_alloc_new_state(&intern->alloc, intern);
@@ -391,7 +391,7 @@
}
lua_atpanic(L, luasandbox_panic);
-
+
// Register the standard library
luasandbox_lib_register(L TSRMLS_CC);
@@ -401,7 +401,7 @@
// Create a table for storing chunks
lua_newtable(L);
lua_setfield(L, LUA_REGISTRYINDEX, "php_luasandbox_chunks");
-
+
// Register a pointer to the PHP object so that C functions can find it
lua_pushlightuserdata(L, (void*)intern);
lua_setfield(L, LUA_REGISTRYINDEX, "php_luasandbox_obj");
@@ -437,7 +437,7 @@
{
php_luasandboxfunction_obj * intern;
zend_object_value retval;
-
+
// Create the internal object
intern =
(php_luasandboxfunction_obj*)emalloc(sizeof(php_luasandboxfunction_obj));
memset(intern, 0, sizeof(php_luasandboxfunction_obj));
@@ -492,7 +492,7 @@
/** {{{ luasandbox_panic
*
* The Lua panic function. It is necessary to raise an E_ERROR, and thus do a
- * longjmp(), since if this function returns, Lua will call exit(), breaking
+ * longjmp(), since if this function returns, Lua will call exit(), breaking
* the Apache child.
*
* Generally, a panic will happen if the Lua API is used incorrectly in an
@@ -501,8 +501,8 @@
* under lua_pcall() so can't cause a panic.
*
* Note that sandboxed Lua code may be executed in an unprotected environment
- * if C code accesses a variable with a metamethod defined by the sandboxed
- * code. For this reason, the "raw" functions such as lua_rawget() should be
+ * if C code accesses a variable with a metamethod defined by the sandboxed
+ * code. For this reason, the "raw" functions such as lua_rawget() should be
* used where this is a possibility.
*/
static int luasandbox_panic(lua_State * L)
@@ -517,12 +517,12 @@
/** {{{ luasandbox_state_from_zval
*
- * Get a lua state from a zval* containing a LuaSandbox object. If the zval*
+ * Get a lua state from a zval* containing a LuaSandbox object. If the zval*
* contains something else, bad things will happen.
*/
static lua_State * luasandbox_state_from_zval(zval * this_ptr TSRMLS_DC)
{
- php_luasandbox_obj * intern = (php_luasandbox_obj*)
+ php_luasandbox_obj * intern = (php_luasandbox_obj*)
zend_object_store_get_object(this_ptr TSRMLS_CC);
return intern->state;
}
@@ -543,12 +543,12 @@
php_luasandbox_obj * sandbox;
int was_paused;
- sandbox = (php_luasandbox_obj*)
+ sandbox = (php_luasandbox_obj*)
zend_object_store_get_object(this_ptr TSRMLS_CC);
L = sandbox->state;
CHECK_VALID_STATE(L);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s",
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s",
&code, &codeLength, &chunkName,
&chunkNameLength) == FAILURE) {
RETURN_FALSE;
}
@@ -558,16 +558,16 @@
} else {
// Check chunkName for nulls
if (strlen(chunkName) != chunkNameLength) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,
"chunk name may not contain null characters");
RETURN_FALSE;
}
}
- // Check to see if the code is binary (with precompiled data mark) if
this
+ // Check to see if the code is binary (with precompiled data mark) if
this
// was called as loadBinary(), and plain code (without mark) if this was
// called as loadString()
- have_mark = (php_memnstr(code, LUA_SIGNATURE,
+ have_mark = (php_memnstr(code, LUA_SIGNATURE,
sizeof(LUA_SIGNATURE) - 1, code + codeLength) != NULL);
if (binary && !have_mark) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
@@ -627,12 +627,12 @@
/* }}} */
-/** {{{ proto LuaSandboxFunction LuaSandbox::loadString(string code, string
chunkName)
+/** {{{ proto LuaSandboxFunction LuaSandbox::loadString(string code, string
chunkName)
*
- * Load a string into the LuaSandbox object. Returns a LuaSandboxFunction
object
+ * Load a string into the LuaSandbox object. Returns a LuaSandboxFunction
object
* which can be called or dumped.
*
- * Note that global functions and variables defined in the chunk will not be
+ * Note that global functions and variables defined in the chunk will not be
* present in the Lua state until the chunk is executed. Function definitions
* in Lua are a kind of executable statement.
*/
@@ -644,8 +644,8 @@
/* }}} */
/** {{{ proto LuaSandboxFunction LuaSandbox::loadBinary(string bin, string
chunkName)
- * Load a string containing a precompiled binary chunk from
- * LuaSandboxFunction::dump() or the Lua compiler luac. Returns a
+ * Load a string containing a precompiled binary chunk from
+ * LuaSandboxFunction::dump() or the Lua compiler luac. Returns a
* LuaSandboxFunction object.
*/
PHP_METHOD(LuaSandbox, loadBinary)
@@ -656,7 +656,7 @@
/** {{{ luasandbox_handle_error
*
- * Handles the error return situation from lua_pcall() and lua_load(), where a
+ * Handles the error return situation from lua_pcall() and lua_load(), where a
* status is returned and an error message pushed to the stack. Throws a
suitable
* exception.
*/
@@ -666,7 +666,7 @@
const char * errorMsg = luasandbox_error_to_string(L, -1);
zend_class_entry * ce;
zval *zex, *ztrace;
-
+
if (EG(exception)) {
lua_pop(L, 1);
return;
@@ -713,7 +713,7 @@
// Initialise standard properties
// We would get Zend to do this, but the code for it is wrapped inside
some
- // very inconvenient interfaces (so inconvenient that Zend itself
+ // very inconvenient interfaces (so inconvenient that Zend itself
// duplicates this code in several places).
zend_update_property_string(ce, zex, "message", sizeof("message")-1,
errorMsg TSRMLS_CC);
zend_update_property_long(ce, zex, "code", sizeof("code")-1, status
TSRMLS_CC);
@@ -727,18 +727,18 @@
*
* Set the memory limit for the Lua state. If the memory limit is exceeded,
* the allocator will return NULL. When running protected code, this will
- * result in a LuaSandboxError exception being thrown. If this occurs in
+ * result in a LuaSandboxError exception being thrown. If this occurs in
* unprotected code, say due to loading too many functions with loadString(),
* a panic will be triggered, leading to a PHP fatal error.
*/
PHP_METHOD(LuaSandbox, setMemoryLimit)
{
long limit;
- php_luasandbox_obj * intern = (php_luasandbox_obj*)
+ php_luasandbox_obj * intern = (php_luasandbox_obj*)
zend_object_store_get_object(getThis() TSRMLS_CC);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
- &limit) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
+ &limit) == FAILURE)
{
RETURN_FALSE;
}
@@ -765,7 +765,7 @@
{
zval *zp_limit = NULL;
- php_luasandbox_obj * sandbox = (php_luasandbox_obj*)
+ php_luasandbox_obj * sandbox = (php_luasandbox_obj*)
zend_object_store_get_object(getThis() TSRMLS_CC);
struct timespec limit = {0, 0};
@@ -817,7 +817,7 @@
/** {{{ proto float LuaSandbox::getCPUUsage()
*
- * Get the amount of CPU used by this LuaSandbox instance, including any PHP
+ * Get the amount of CPU used by this LuaSandbox instance, including any PHP
* functions called by Lua.
*/
PHP_METHOD(LuaSandbox, getCPUUsage)
@@ -892,9 +892,9 @@
*
* Enable the profiler. Profiling will begin when Lua code is entered.
*
- * We use a sampling profiler, with samples taken with the specified sampling
- * period, in seconds. Testing indicates that at least on Linux, setting a
- * period less than 1ms will lead to a high overrun count but no performance
+ * We use a sampling profiler, with samples taken with the specified sampling
+ * period, in seconds. Testing indicates that at least on Linux, setting a
+ * period less than 1ms will lead to a high overrun count but no performance
* problems.
*/
PHP_METHOD(LuaSandbox, enableProfiler)
@@ -906,7 +906,7 @@
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|d", &period) ==
FAILURE) {
RETURN_FALSE;
}
-
+
luasandbox_set_timespec(&ts, period);
RETURN_BOOL(luasandbox_timer_enable_profiler(&sandbox->timer, &ts));
}
@@ -950,7 +950,7 @@
*
* For a profiling instance previously started by enableProfiler(), get a
report
* of the cost of each function. The return value will be an associative array
- * mapping the function name (with source file and line defined in angle
+ * mapping the function name (with source file and line defined in angle
* brackets) to the cost.
*
* The measurement unit used for the cost is determined by the what parameter:
@@ -972,7 +972,7 @@
&& units != LUASANDBOX_SAMPLES
&& units != LUASANDBOX_PERCENT )
{
- php_error_docref(NULL TSRMLS_CC, E_WARNING,
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,
"invalid value for \"units\" passed to
LuaSandbox::getProfilerFunctionReport");
RETURN_FALSE;
}
@@ -982,7 +982,7 @@
array_init(return_value);
return;
}
-
+
// Sort the input array in descending order of time usage
zend_hash_sort(counts, zend_qsort, luasandbox_sort_profile, 0
TSRMLS_CC);
@@ -1059,15 +1059,15 @@
/** {{{ proto array LuaSandbox::callFunction(string name, ...)
*
- * Call a function in the global variable with the given name. The name may
+ * Call a function in the global variable with the given name. The name may
* contain "." characters, in which case the function is located via recursive
* table accesses, as if the name were a Lua expression.
*
* If the variable does not exist, or is not a function, false will be returned
* and a warning issued.
*
- * Any arguments specified after the name will be passed through as arguments
- * to the function.
+ * Any arguments specified after the name will be passed through as arguments
+ * to the function.
*
* For more information about calling Lua functions and the return values, see
* LuaSandboxFunction::call().
@@ -1107,7 +1107,7 @@
}
/* }}} */
-/** {{{ proto LuaSandboxFunction LuaSandbox::wrapPhpFunction(callable
function)
+/** {{{ proto LuaSandboxFunction LuaSandbox::wrapPhpFunction(callable function)
*
* Wrap a PHP callable in a LuaSandboxFunction, so it can be passed into Lua as
* an anonymous function.
@@ -1150,13 +1150,13 @@
* Common initialisation for LuaSandboxFunction methods. Initialise the
* function, state and sandbox pointers, and push the function to the stack.
*/
-static int luasandbox_function_init(zval * this_ptr,
php_luasandboxfunction_obj ** pfunc,
+static int luasandbox_function_init(zval * this_ptr,
php_luasandboxfunction_obj ** pfunc,
lua_State ** pstate, php_luasandbox_obj ** psandbox TSRMLS_DC)
{
*pfunc = (php_luasandboxfunction_obj *)
zend_object_store_get_object(this_ptr TSRMLS_CC);
if (!*pfunc || !(*pfunc)->sandbox || !(*pfunc)->index) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,
"attempt to call uninitialized LuaSandboxFunction
object" );
return 0;
}
@@ -1183,7 +1183,7 @@
/* {{{ proto private final LuaSandboxFunction::__construct()
*
- * Construct a LuaSandboxFunction object. Do not call this directly, use
+ * Construct a LuaSandboxFunction object. Do not call this directly, use
* LuaSandbox::loadString().
*/
PHP_METHOD(LuaSandboxFunction, __construct)
@@ -1197,21 +1197,21 @@
* Call a LuaSandboxFunction. The arguments to this function are passed through
* to Lua.
*
- * Errors considered to be the fault of the PHP code will result in the
+ * Errors considered to be the fault of the PHP code will result in the
* function returning false and E_WARNING being raised, for example, a
- * resource type being used as an argument. Lua errors will result in a
+ * resource type being used as an argument. Lua errors will result in a
* LuaSandboxError exception being thrown.
*
- * Lua functions inherently return a list of results. So on success, this
- * function returns an array containing all of the values returned by Lua,
- * with integer keys starting from zero. Lua may return no results, in which
+ * Lua functions inherently return a list of results. So on success, this
+ * function returns an array containing all of the values returned by Lua,
+ * with integer keys starting from zero. Lua may return no results, in which
* case an empty array is returned.
*/
PHP_METHOD(LuaSandboxFunction, call)
{
zend_uint numArgs = 0;
zval *** args = NULL;
-
+
php_luasandboxfunction_obj * func;
lua_State * L;
php_luasandbox_obj * sandbox;
@@ -1309,7 +1309,7 @@
* Call the function at the top of the stack and then pop it. Set return_value
* to an array containing all the results.
*/
-static void luasandbox_call_helper(lua_State * L, zval * sandbox_zval,
php_luasandbox_obj * sandbox,
+static void luasandbox_call_helper(lua_State * L, zval * sandbox_zval,
php_luasandbox_obj * sandbox,
zval *** args, zend_uint numArgs, zval * return_value TSRMLS_DC)
{
// Save the top position
@@ -1367,7 +1367,7 @@
zval_ptr_dtor(&element);
break;
}
- zend_hash_next_index_insert(Z_ARRVAL_P(return_value),
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value),
(void*)&element,
sizeof(zval*), NULL);
}
@@ -1379,12 +1379,12 @@
/** {{{ luasandbox_find_field
*
- * Given a string in the format "a.b.c.d" find the relevant variable in the
+ * Given a string in the format "a.b.c.d" find the relevant variable in the
* table at the given stack position. If it is found, 1 is returned
* and the variable will be pushed to the stack. If not, 0 is returned
* and the stack will be in the original state.
*/
-static int luasandbox_find_field(lua_State * L, int index,
+static int luasandbox_find_field(lua_State * L, int index,
char * spec, int specLength)
{
int i;
@@ -1396,7 +1396,7 @@
lua_pushvalue(L, index);
spec = estrndup(spec, specLength);
-
+
for (i = 0; i <= specLength; i++) {
if (i == specLength || spec[i] == '.') {
// Put the next item into top+2
@@ -1445,18 +1445,18 @@
* relevant PHP code.
*
* The first parameter is the name of the library. In the Lua state, the global
- * variable of this name will be set to the table of functions. If the table
+ * variable of this name will be set to the table of functions. If the table
* already exists, the new functions will be added to it.
*
- * The second parameter is an array, where each key is a function name, and
+ * The second parameter is an array, where each key is a function name, and
* each value is a corresponding PHP callback.
*
- * Both Lua and PHP allow functions to be called with any number of arguments.
- * The parameters to the Lua function will be passed through to the PHP.
+ * Both Lua and PHP allow functions to be called with any number of arguments.
+ * The parameters to the Lua function will be passed through to the PHP.
*
- * Lua supports multiple return values. The PHP function should return either
+ * Lua supports multiple return values. The PHP function should return either
* null (for zero return values) or an array of return values. The keys of the
- * return array will not be used, rather the values will be taken in their
+ * return array will not be used, rather the values will be taken in their
* internal order.
*/
PHP_METHOD(LuaSandbox, registerLibrary)
@@ -1544,13 +1544,13 @@
/** {{{ luasandbox_call_php
*
- * The Lua callback for calling PHP functions. See the doc comment on
+ * The Lua callback for calling PHP functions. See the doc comment on
* LuaSandbox::registerLibrary() for information about calling conventions.
*/
int luasandbox_call_php(lua_State * L)
{
php_luasandbox_obj * intern = luasandbox_get_php_obj(L);
-
+
luasandbox_enter_php(L, intern);
zval ** callback_pp = (zval**)lua_touserdata(L, lua_upvalueindex(1));
@@ -1565,17 +1565,17 @@
zval ***double_pointers;
int num_results = 0;
int status;
- HashPosition p;
+ HashPosition p;
HashTable * ht;
TSRMLS_FETCH();
// Based on zend_parse_arg_impl()
- if (zend_fcall_info_init(*callback_pp, 0, &fci, &fcc, NULL,
+ if (zend_fcall_info_init(*callback_pp, 0, &fci, &fcc, NULL,
&is_callable_error TSRMLS_CC) != SUCCESS)
{
- // Handle errors similar to the way PHP does it: show a warning
and
+ // Handle errors similar to the way PHP does it: show a warning
and
// return nil
- php_error_docref(NULL TSRMLS_CC, E_WARNING,
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,
"to be a valid callback, %s", is_callable_error);
efree(is_callable_error);
lua_pushnil(L);
@@ -1636,7 +1636,7 @@
num_results++;
}
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,
"function tried to return a single
value to Lua without wrapping it in an array");
}
zval_ptr_dtor(&retval_ptr);
@@ -1663,7 +1663,7 @@
lua_pushliteral(L, "[unknown exception]");
}
- // If the exception was a LuaSandboxRuntimeError or a subclass,
clear the
+ // If the exception was a LuaSandboxRuntimeError or a subclass,
clear the
// exception and raise a non-fatal (catchable) error
if (luasandbox_instanceof(ce, luasandboxruntimeerror_ce)) {
zend_clear_exception(TSRMLS_C);
@@ -1679,7 +1679,7 @@
/** {{{ string LuaSandboxFunction::dump()
*
* Dump the function as a precompiled binary blob. Returns a string which may
- * later be loaded by LuaSandbox::loadBinary(), in the same or a different
+ * later be loaded by LuaSandbox::loadBinary(), in the same or a different
* sandbox object.
*/
PHP_METHOD(LuaSandboxFunction, dump)
@@ -1696,7 +1696,7 @@
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
return;
}
-
+
lua_dump(L, luasandbox_dump_writer, (void*)&buf);
smart_str_0(&buf);
if (buf.len) {
diff --git a/luasandbox_types.h b/luasandbox_types.h
index 57500f6..a5e5a4c 100644
--- a/luasandbox_types.h
+++ b/luasandbox_types.h
@@ -30,9 +30,9 @@
int limiter_running;
int profiler_running;
- // A HashTable storing the number of times each function was hit by the
+ // A HashTable storing the number of times each function was hit by the
// profiler. The data is a size_t because that hits a special case in
- // zend_hash which avoids the need to allocate separate space for the
data
+ // zend_hash which avoids the need to allocate separate space for the
data
// on the heap.
HashTable * function_counts;
diff --git a/php_luasandbox.h b/php_luasandbox.h
index 1f4edd7..b5dc6a4 100644
--- a/php_luasandbox.h
+++ b/php_luasandbox.h
@@ -78,11 +78,11 @@
/** {{{ luasandbox_enter_php
*
* This function must be called each time a C function is entered from Lua
- * and the PHP state needs to be accessed in any way. Before exiting the
+ * and the PHP state needs to be accessed in any way. Before exiting the
* function, luasandbox_leave_php() must be called.
*
- * This sets a flag which indicates to the timeout signal handler that it is
- * unsafe to call longjmp() to return control to PHP. If the flag is not
+ * This sets a flag which indicates to the timeout signal handler that it is
+ * unsafe to call longjmp() to return control to PHP. If the flag is not
* correctly set, memory may be corrupted and security compromised.
*/
static inline void luasandbox_enter_php(lua_State * L, php_luasandbox_obj *
intern)
@@ -107,7 +107,7 @@
/** {{{ luasandbox_leave_php
*
- * This function must be called after luasandbox_enter_php, before the
callback
+ * This function must be called after luasandbox_enter_php, before the callback
* from Lua returns.
*/
static inline void luasandbox_leave_php(lua_State * L, php_luasandbox_obj *
intern)
diff --git a/timer.c b/timer.c
index 8a96661..98494e6 100644
--- a/timer.c
+++ b/timer.c
@@ -158,10 +158,10 @@
// It's necessary to leave the timer running while we're not actually in
// Lua, and just ignore signals that occur outside it, because Linux
timers
// don't fire with any kind of precision. Timer delivery is routinely
delayed
- // by milliseconds regardless of how short a time you ask for, and
- // timer_gettime() just returns 1ns after the timer should have been
delivered.
- // So if a call takes 100us, there's no way to start a timer and have
it be
- // reliably delivered to within the function body, regardless of what
you set
+ // by milliseconds regardless of how short a time you ask for, and
+ // timer_gettime() just returns 1ns after the timer should have been
delivered.
+ // So if a call takes 100us, there's no way to start a timer and have
it be
+ // reliably delivered to within the function body, regardless of what
you set
// it_value to.
php_luasandbox_obj * sandbox = lt->sandbox;
if (!sandbox || !sandbox->in_lua) {
@@ -172,7 +172,7 @@
if (!sandbox->timed_out) {
int overrun;
lua_State * L = sandbox->state;
- lua_sethook(L, luasandbox_timer_profiler_hook,
+ lua_sethook(L, luasandbox_timer_profiler_hook,
LUA_MASKCOUNT | LUA_MASKCALL | LUA_MASKRET |
LUA_MASKLINE, 1);
overrun =
timer_getoverrun(sandbox->timer.profiler_timer->timer);
sandbox->timer.profiler_signal_count += overrun + 1;
--
To view, visit https://gerrit.wikimedia.org/r/298310
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic8b601ac305cc7abe60982d0d7fe1b4466d6536f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/php/luasandbox
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits