From 8082efd6deab856d21531f14aa32ae0eba4baacb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20S=C3=A1nchez=20Parra?= Date: Mon, 4 Nov 2019 10:52:01 +0100 Subject: [PATCH] #924 Always check the result of a command to avoid errors Irina reports that if you try to restore an image without success (for example: the disk does not have enough space), the database changes as if no error would happen. So you see the computer in the WebConsole with an image/OS that, actually, does not have. The bug is caused because the function respuestaEstandar only checks the result of a command if it has a session. So the problem is that the commands which use respuestaEstandar without a session can return an error, but the ogAdmServer always works as no error would occur. This commit changes the behaviour of respuestaEstadar to always check the result of a command, whether it has a session or not. --- sources/ogAdmServer.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/sources/ogAdmServer.cpp b/sources/ogAdmServer.cpp index 025bfcd..ab8e5f5 100644 --- a/sources/ogAdmServer.cpp +++ b/sources/ogAdmServer.cpp @@ -1068,13 +1068,25 @@ static bool respuestaEstandar(TRAMA *ptrTrama, char *iph, char *ido, Database db struct tm* st; int idaccion; - ids = copiaParametro("ids",ptrTrama); // Toma identificador de la sesión + ids = copiaParametro("ids",ptrTrama); + res = copiaParametro("res",ptrTrama); - if (ids == NULL) // No existe seguimiento de la acción + if (ids == NULL) { + if (atoi(res) == ACCION_FALLIDA) { + liberaMemoria(res); + return false; + } + liberaMemoria(res); return true; + } - if (atoi(ids) == 0){ // No existe seguimiento de la acción + if (atoi(ids) == 0) { liberaMemoria(ids); + if (atoi(res) == ACCION_FALLIDA) { + liberaMemoria(res); + return false; + } + liberaMemoria(res); return true; } @@ -1103,7 +1115,6 @@ static bool respuestaEstandar(TRAMA *ptrTrama, char *iph, char *ido, Database db sprintf(fechafin, "%d/%d/%d %d:%d:%d", st->tm_year + 1900, st->tm_mon + 1, st->tm_mday, st->tm_hour, st->tm_min, st->tm_sec); - res = copiaParametro("res",ptrTrama); // Toma resultado der = copiaParametro("der",ptrTrama); // Toma descripción del error (si hubiera habido) sprintf(sqlstr, @@ -1121,11 +1132,6 @@ static bool respuestaEstandar(TRAMA *ptrTrama, char *iph, char *ido, Database db } liberaMemoria(der); - - if (atoi(res) == ACCION_FALLIDA) { - liberaMemoria(res); - return false; // Error en la ejecución del comando - } liberaMemoria(res); return true;