Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,11 @@ class ContainerQuery
correctedstring = stringToTruncate + "\"]";
}
instance.EnvironmentVar_value(correctedstring.c_str());
syslog(LOG_WARNING, "Environment variable truncated for container %s", cJSON_GetObjectItem(entry, "Id")->valuestring);
cJSON* idItem = cJSON_GetObjectItem(entry, "Id");
if (idItem != NULL)
{
syslog(LOG_WARNING, "Environment variable truncated for container %s", idItem->valuestring);
}
}
else {
instance.EnvironmentVar_value(strcmp(env, "null") ? env : "");
Expand Down Expand Up @@ -244,9 +248,10 @@ class ContainerQuery
}
else
{
if (cJSON_GetObjectItem(entry, "Id") != NULL)
cJSON* idItem = cJSON_GetObjectItem(entry, "Id");
if (idItem != NULL)
{
syslog(LOG_WARNING, "Attempt in ObtainContainerConfig to get container %s config information returned null", cJSON_GetObjectItem(entry, "Id")->valuestring);
syslog(LOG_WARNING, "Attempt in ObtainContainerConfig to get container %s config information returned null", idItem->valuestring);
}
}
}
Expand Down Expand Up @@ -281,9 +286,10 @@ class ContainerQuery
if (exitCode < 0)
{
exitCode = 128;
if (cJSON_GetObjectItem(entry, "Id") != NULL)
cJSON* idItem = cJSON_GetObjectItem(entry, "Id");
if (idItem != NULL)
{
syslog(LOG_NOTICE, "Container %s returned negative exit code", cJSON_GetObjectItem(entry, "Id")->valuestring);
syslog(LOG_NOTICE, "Container %s returned negative exit code", idItem->valuestring);
}
}

Expand Down Expand Up @@ -334,9 +340,10 @@ class ContainerQuery
}
else
{
if (cJSON_GetObjectItem(entry, "Id"))
cJSON* idItem = cJSON_GetObjectItem(entry, "Id");
if (idItem)
{
syslog(LOG_WARNING, "Attempt in ObtainContainerState to get container %s state information returned null", cJSON_GetObjectItem(entry, "Id")->valuestring);
syslog(LOG_WARNING, "Attempt in ObtainContainerState to get container %s state information returned null", idItem->valuestring);
}
}
}
Expand Down Expand Up @@ -381,9 +388,10 @@ class ContainerQuery
}
else
{
if (cJSON_GetObjectItem(entry, "Id"))
cJSON* idItem = cJSON_GetObjectItem(entry, "Id");
if (idItem != NULL)
{
syslog(LOG_WARNING, "Attempt in ObtainContainerHostConfig to get container %s host config information returned null", cJSON_GetObjectItem(entry, "Id")->valuestring);
syslog(LOG_WARNING, "Attempt in ObtainContainerHostConfig to get container %s host config information returned null", idItem->valuestring);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,11 @@ class EventQuery
}
else
{
cJSON* idItem = cJSON_GetObjectItem(entry, "id");
// Image event
if (cJSON_GetObjectItem(entry, "id") != NULL)
if (idItem != NULL)
{
instance.ElementName_value(cJSON_GetObjectItem(entry, "id")->valuestring);
instance.ElementName_value(idItem->valuestring);
}
instance.Id_value("");
instance.ContainerName_value("");
Expand Down
16 changes: 10 additions & 6 deletions source/code/providers/Container_ImageInventory_Class_Provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,12 @@ class InventoryQuery
{
string id = string(objItem->valuestring);

if (cJSON_GetObjectItem(state, "Running") != NULL && cJSON_GetObjectItem(state, "Running")->valueint)
cJSON* runningItem = cJSON_GetObjectItem(state, "Running");
if (runningItem != NULL && runningItem->valueint)
{
// Running container
if (cJSON_GetObjectItem(state, "Paused") != NULL && cJSON_GetObjectItem(state, "Paused")->valueint)
cJSON* pausedItem = cJSON_GetObjectItem(state, "Paused");
if (pausedItem != NULL && pausedItem->valueint)
{
// Paused container
instances[idTable[id]].Paused_value(instances[idTable[id]].Paused_value() + 1);
Expand All @@ -188,7 +190,8 @@ class InventoryQuery
}
else
{
if (cJSON_GetObjectItem(state, "ExitCode") != NULL && cJSON_GetObjectItem(state, "ExitCode")->valueint)
cJSON* exitCodeItem = cJSON_GetObjectItem(state, "ExitCode");
if (exitCodeItem != NULL && exitCodeItem->valueint)
{
// Container exited nonzero
instances[idTable[id]].Failed_value(instances[idTable[id]].Failed_value() + 1);
Expand All @@ -206,9 +209,10 @@ class InventoryQuery
}
else
{
if (cJSON_GetObjectItem(entry, "Id") != NULL)
cJSON* idItem = cJSON_GetObjectItem(entry, "Id");
if (idItem != NULL)
{
syslog(LOG_WARNING, "Attempt in ObtainContainerState to get container %s state information returned null", cJSON_GetObjectItem(entry, "Id")->valuestring);
syslog(LOG_WARNING, "Attempt in ObtainContainerState to get container %s state information returned null", idItem->valuestring);
}
}
}
Expand Down Expand Up @@ -263,7 +267,7 @@ class InventoryQuery
}
else
{
syslog(LOG_WARNING, "API call in AggregateContainerStatus to inspect container %s returned null", cJSON_GetObjectItem(entry, "Id")->valuestring);
syslog(LOG_WARNING, "API call in AggregateContainerStatus to inspect container %s returned null", objItem->valuestring);
}
}
}
Expand Down