Skip to content

Commit 05f93ec

Browse files
author
efiocca
committed
Added null check on second registration response and logic to check API response for errors
1 parent 0f49f61 commit 05f93ec

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

session.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,12 +483,19 @@ static int do_second_registration(struct SessionInfo* session,
483483
}
484484

485485
resp = SessionRegisterResp_fromJson(respString);
486-
if (resp) {
487-
log_trace("%s::%s(%d): response decoded. Now parsing response.", LOG_INF);
488-
} else {
489-
log_error("%s::%s(%d) : No Session was found in the response", LOG_INF);
486+
if ( NULL == resp ) {
487+
log_error("%s::%s(%d) : Could not decode response", LOG_INF);
488+
httpRes = 997;
490489
goto exit;
491490
}
491+
log_debug("%s::%s(%d): response decoded. Now parsing response.",
492+
LOG_INF);
493+
if( !AgentApiResult_log(resp->Result, NULL, NULL) ) {
494+
if(resp->Result.Status == STAT_ERR) {
495+
log_error("%s::%s(%d): Command reported an error during the second registration call", LOG_INF);
496+
httpRes = 997;
497+
}
498+
}
492499

493500
if(resp->Session.Token) {
494501
log_info("%s::%s(%d): New session %s contains %d jobs", LOG_INF, resp->Session.Token, resp->Session.Jobs_count);

0 commit comments

Comments
 (0)