webmcp

changeset 372:32b64f641761

Workaround for issue with noncompliant (_GNU_SOURCE) strerror_r() implementation
author jbe
date Sat Aug 22 18:19:11 2015 +0200 (2015-08-22)
parents 54b5b59e3c10
children 7674d59521f8
files libraries/extos/extos.c
line diff
     1.1 --- a/libraries/extos/extos.c	Fri Aug 07 21:44:56 2015 +0200
     1.2 +++ b/libraries/extos/extos.c	Sat Aug 22 18:19:11 2015 +0200
     1.3 @@ -17,6 +17,8 @@
     1.4  #define EXTOS_MAX_ERRLEN 80
     1.5  #define EXTOS_EXEC_MAX_ARGS 64
     1.6  
     1.7 +#define EXTOS_STRERROR_R_MSG "Error detail unavailable due to noncompliant strerror_r() implementation"
     1.8 +
     1.9  static lua_Number extos_monotonic_start_time;
    1.10  
    1.11  static int extos_pfilter(lua_State *L) {
    1.12 @@ -44,7 +46,7 @@
    1.13    int out_closed = 0;
    1.14    int err_closed = 0;
    1.15    void *newptr;
    1.16 -  char errmsg[EXTOS_MAX_ERRLEN+1];
    1.17 +  char errmsg[EXTOS_MAX_ERRLEN+1] = EXTOS_STRERROR_R_MSG;
    1.18    in_buf = luaL_optlstring(L, 1, "", &in_len);
    1.19    filename = luaL_checkstring(L, 2);
    1.20    args[0] = filename;
    1.21 @@ -305,7 +307,7 @@
    1.22      const char *filename;
    1.23      filename = luaL_checkstring(L, 1);
    1.24      if (fd == EXTOS_STAT_FOLLOW ? stat(filename, &sb) : lstat(filename, &sb)) {
    1.25 -      char errmsg[EXTOS_MAX_ERRLEN+1];
    1.26 +      char errmsg[EXTOS_MAX_ERRLEN+1] = EXTOS_STRERROR_R_MSG;
    1.27        strerror_r(errno, errmsg, EXTOS_MAX_ERRLEN+1);
    1.28        if (errno == ENOENT) lua_pushboolean(L, 0);
    1.29        else lua_pushnil(L);
    1.30 @@ -314,7 +316,7 @@
    1.31      }
    1.32    } else {
    1.33      if (fstat(fd, &sb)) {
    1.34 -      char errmsg[EXTOS_MAX_ERRLEN+1];
    1.35 +      char errmsg[EXTOS_MAX_ERRLEN+1] = EXTOS_STRERROR_R_MSG;
    1.36        strerror_r(errno, errmsg, EXTOS_MAX_ERRLEN+1);
    1.37        lua_pushnil(L);
    1.38        lua_pushfstring(L, "Could not get file stats for open file: %s", errmsg);

Impressum / About Us