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Ă© <[email protected]>
---
Cc: Ian Jackson <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Ian Campbell <[email protected]>
Cc: Wei Liu <[email protected]>
---
Changes since v1:
 - Use a default buffer size if sysconf(_SC_GETPW_R_SIZE_MAX) fails for any
   reason, this should not be a critical failure.
---
 tools/libxl/libxl_dm.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 0aaefd9..a088d71 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -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) {
-- 
1.9.5 (Apple Git-50.3)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reply via email to