mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
lua, perl: Use thread-safe strerror_r instead of strerror (RHBZ#1536763).
This commit is contained in:
@@ -142,6 +142,7 @@ guestfs_int_lua_create (lua_State *L)
|
||||
guestfs_h *g;
|
||||
struct userdata *u;
|
||||
unsigned flags = 0;
|
||||
char err[256];
|
||||
|
||||
if (lua_gettop (L) == 1) {
|
||||
OPTARG_IF_SET (1, \"environment\",
|
||||
@@ -157,9 +158,10 @@ guestfs_int_lua_create (lua_State *L)
|
||||
return luaL_error (L, \"Guestfs.create: too many arguments\");
|
||||
|
||||
g = guestfs_create_flags (flags);
|
||||
if (!g)
|
||||
return luaL_error (L, \"Guestfs.create: cannot create handle: %%s\",
|
||||
strerror (errno));
|
||||
if (!g) {
|
||||
strerror_r (errno, err, sizeof err);
|
||||
return luaL_error (L, \"Guestfs.create: cannot create handle: %%s\", err);
|
||||
}
|
||||
|
||||
guestfs_set_error_handler (g, NULL, NULL);
|
||||
|
||||
@@ -226,6 +228,7 @@ error__tostring (lua_State *L)
|
||||
{
|
||||
int code;
|
||||
const char *msg;
|
||||
char err[256];
|
||||
|
||||
lua_pushliteral (L, \"code\");
|
||||
lua_gettable (L, 1);
|
||||
@@ -234,8 +237,10 @@ error__tostring (lua_State *L)
|
||||
lua_gettable (L, 1);
|
||||
msg = luaL_checkstring (L, -1);
|
||||
|
||||
if (code)
|
||||
lua_pushfstring (L, \"%%s: %%s\", msg, strerror (code));
|
||||
if (code) {
|
||||
strerror_r (code, err, sizeof err);
|
||||
lua_pushfstring (L, \"%%s: %%s\", msg, err);
|
||||
}
|
||||
else
|
||||
lua_pushstring (L, msg);
|
||||
|
||||
@@ -640,11 +645,12 @@ get_string_list (lua_State *L, int index)
|
||||
const size_t len = lua_objlen (L, index);
|
||||
size_t i;
|
||||
char **strs;
|
||||
char err[256];
|
||||
|
||||
strs = malloc ((len+1) * sizeof (char *));
|
||||
if (strs == NULL) {
|
||||
luaL_error (L, \"get_string_list: malloc failed: %%s\",
|
||||
strerror (errno));
|
||||
strerror_r (errno, err, sizeof err);
|
||||
luaL_error (L, \"get_string_list: malloc failed: %%s\", err);
|
||||
/*NOTREACHED*/
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ PREINIT:
|
||||
CODE:
|
||||
str = guestfs_event_to_string (event_bitmask);
|
||||
if (str == NULL)
|
||||
croak (\"%%s\", strerror (errno));
|
||||
croak (\"%%m\");
|
||||
RETVAL = newSVpv (str, 0);
|
||||
free (str);
|
||||
OUTPUT:
|
||||
|
||||
@@ -41,6 +41,7 @@ libluaguestfs_la_SOURCES = lua-guestfs.c
|
||||
|
||||
libluaguestfs_la_CPPFLAGS = \
|
||||
-DGUESTFS_PRIVATE=1 \
|
||||
-I$(srcdir)/../gnulib/lib -I../gnulib/lib \
|
||||
-I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
|
||||
-I$(top_srcdir)/lib -I$(top_builddir)/lib
|
||||
|
||||
|
||||
Reference in New Issue
Block a user