]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commitdiff
libxl: fix _SC_GETPW_R_SIZE_MAX usage
authorRoger Pau Monne <roger.pau@citrix.com>
Thu, 14 Jan 2016 15:06:50 +0000 (16:06 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 15 Jan 2016 10:32:24 +0000 (10:32 +0000)
If sysconf(_SC_GETPW_R_SIZE_MAX) fails for any reason just use an initial
buffer size of 2048. This is not a critical failure, and the code that
makes use of this buffer is able to expand it later if required.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxl_dm.c

index 0aaefd957242e426ea909c70077d095f4d6c9392..a088d71160903aca4f7522a0867e8c42556a015d 100644 (file)
@@ -730,9 +730,10 @@ static int libxl__dm_runas_helper(libxl__gc *gc, const char *username)
 
     buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
     if (buf_size < 0) {
-        LOGE(ERROR, "sysconf(_SC_GETPW_R_SIZE_MAX) returned error %ld",
-                buf_size);
-        return ERROR_FAIL;
+        buf_size = 2048;
+        LOG(DEBUG,
+"sysconf(_SC_GETPW_R_SIZE_MAX) failed, setting the initial buffer size to %ld",
+            buf_size);
     }
 
     while (1) {