提交 cdf7a40d 编写于 作者: M Matthias Bolte

phyp: Check for exit_status < 0 before parsing the result

上级 7ecb50c2
...@@ -508,7 +508,7 @@ phypGetLparNAME(LIBSSH2_SESSION * session, const char *managed_system, ...@@ -508,7 +508,7 @@ phypGetLparNAME(LIBSSH2_SESSION * session, const char *managed_system,
ret = phypExec(session, cmd, &exit_status, conn); ret = phypExec(session, cmd, &exit_status, conn);
if (ret == NULL) if (exit_status < 0 || ret == NULL)
goto err; goto err;
char *char_ptr = strchr(ret, '\n'); char *char_ptr = strchr(ret, '\n');
...@@ -516,9 +516,6 @@ phypGetLparNAME(LIBSSH2_SESSION * session, const char *managed_system, ...@@ -516,9 +516,6 @@ phypGetLparNAME(LIBSSH2_SESSION * session, const char *managed_system,
if (char_ptr) if (char_ptr)
*char_ptr = '\0'; *char_ptr = '\0';
if (exit_status < 0 || ret == NULL)
goto err;
VIR_FREE(cmd); VIR_FREE(cmd);
return ret; return ret;
...@@ -593,16 +590,13 @@ phypGetLparMem(virConnectPtr conn, const char *managed_system, int lpar_id, ...@@ -593,16 +590,13 @@ phypGetLparMem(virConnectPtr conn, const char *managed_system, int lpar_id,
ret = phypExec(session, cmd, &exit_status, conn); ret = phypExec(session, cmd, &exit_status, conn);
if (ret == NULL) if (exit_status < 0 || ret == NULL)
goto err; goto err;
char *mem_char_ptr = strchr(ret, '\n'); char_ptr = strchr(ret, '\n');
if (mem_char_ptr)
*mem_char_ptr = '\0';
if (exit_status < 0) if (char_ptr)
goto err; *char_ptr = '\0';
if (virStrToLong_i(ret, &char_ptr, 10, &memory) == -1) if (virStrToLong_i(ret, &char_ptr, 10, &memory) == -1)
goto err; goto err;
...@@ -641,6 +635,7 @@ phypGetLparCPUGeneric(virConnectPtr conn, const char *managed_system, ...@@ -641,6 +635,7 @@ phypGetLparCPUGeneric(virConnectPtr conn, const char *managed_system,
LIBSSH2_SESSION *session = connection_data->session; LIBSSH2_SESSION *session = connection_data->session;
char *cmd = NULL; char *cmd = NULL;
char *ret = NULL; char *ret = NULL;
char *char_ptr;
int exit_status = 0; int exit_status = 0;
int vcpus = 0; int vcpus = 0;
...@@ -663,10 +658,10 @@ phypGetLparCPUGeneric(virConnectPtr conn, const char *managed_system, ...@@ -663,10 +658,10 @@ phypGetLparCPUGeneric(virConnectPtr conn, const char *managed_system,
} }
ret = phypExec(session, cmd, &exit_status, conn); ret = phypExec(session, cmd, &exit_status, conn);
if (ret == NULL) if (exit_status < 0 || ret == NULL)
goto err; goto err;
char *char_ptr = strchr(ret, '\n'); char_ptr = strchr(ret, '\n');
if (char_ptr) if (char_ptr)
*char_ptr = '\0'; *char_ptr = '\0';
...@@ -674,9 +669,6 @@ phypGetLparCPUGeneric(virConnectPtr conn, const char *managed_system, ...@@ -674,9 +669,6 @@ phypGetLparCPUGeneric(virConnectPtr conn, const char *managed_system,
if (virStrToLong_i(ret, &char_ptr, 10, &vcpus) == -1) if (virStrToLong_i(ret, &char_ptr, 10, &vcpus) == -1)
goto err; goto err;
if (exit_status < 0)
goto err;
VIR_FREE(cmd); VIR_FREE(cmd);
VIR_FREE(ret); VIR_FREE(ret);
return (unsigned long) vcpus; return (unsigned long) vcpus;
...@@ -708,16 +700,13 @@ phypGetRemoteSlot(virConnectPtr conn, const char *managed_system, ...@@ -708,16 +700,13 @@ phypGetRemoteSlot(virConnectPtr conn, const char *managed_system,
} }
ret = phypExec(session, cmd, &exit_status, conn); ret = phypExec(session, cmd, &exit_status, conn);
if (ret == NULL) if (exit_status < 0 || ret == NULL)
goto err; goto err;
char *char_ptr2 = strchr(ret, '\n'); char_ptr = strchr(ret, '\n');
if (char_ptr2)
*char_ptr2 = '\0';
if (exit_status < 0) if (char_ptr)
goto err; *char_ptr = '\0';
if (virStrToLong_i(ret, &char_ptr, 10, &remote_slot) == -1) if (virStrToLong_i(ret, &char_ptr, 10, &remote_slot) == -1)
goto err; goto err;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册