Skip to content

Commit

Permalink
Merge pull request #736 from microsoft/omi/1.6.12-1
Browse files Browse the repository at this point in the history
1.6.12 1release
  • Loading branch information
Yash-Khatri committed Feb 16, 2023
2 parents 0b31515 + 3a93c51 commit 9d143af
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 42 deletions.
6 changes: 6 additions & 0 deletions Unix/base/preexec.c
Expand Up @@ -17,6 +17,7 @@
#if defined(CONFIG_POSIX)
# include <pthread.h>
# include <errno.h>
# include <fcntl.h>
# include <unistd.h>
# include <sys/types.h>
# include <sys/wait.h>
Expand Down Expand Up @@ -299,6 +300,11 @@ int PreExec_ExecuteOnServer(
close(fd);
}

/* Re-open fd 0,1,2. */
open("/dev/null", O_RDONLY);
open("/dev/null", O_RDWR);
open("/dev/null", O_RDWR);

dup2(STDOUT_FILENO, STDOUT_FILENO);
dup2(STDERR_FILENO, STDERR_FILENO);

Expand Down
5 changes: 5 additions & 0 deletions Unix/base/user.c
Expand Up @@ -218,6 +218,11 @@ static int _CreateChildProcess(
}
}

/* Re-open fd 0,1,2. */
open("/dev/null", O_RDONLY);
open("/dev/null", O_RDWR);
open("/dev/null", O_RDWR);

/* perform operation in quesiton */
{
int r = PamCheckUser(user, password);
Expand Down
8 changes: 8 additions & 0 deletions Unix/cli/cli_c.c
Expand Up @@ -695,6 +695,7 @@ static MI_Result ConsumeInstanceResults(MI_Operation *miOperation)
MI_Uint32 clientBufferLength = c_initBufferLength;
MI_Uint32 clientBufferNeeded = 0;
clientBuffer = (MI_Uint8*)malloc(clientBufferLength + 1);
if(!clientBuffer) return MI_RESULT_FAILED;
MI_Application_Initialize(0,NULL,NULL, &application);
miResult = XmlSerializer_Create(&application, 0, MI_T("MI_XML"), &serializer);
if (miResult != MI_RESULT_OK)
Expand Down Expand Up @@ -788,6 +789,13 @@ static MI_Result ConsumeInstanceResults(MI_Operation *miOperation)
// Try again with a buffer given to us by the clientBufferNeeded field
clientBufferLength = clientBufferNeeded;
clientBuffer = (MI_Uint8*)malloc(clientBufferLength + 1);
if(!clientBuffer)
{
XmlSerializer_Close(&serializer);
MI_Application_Close(&application);
return MI_RESULT_FAILED;
}

miResult = XmlSerializer_SerializeInstance(&serializer, 0, miInstanceResult, clientBuffer, clientBufferLength, &clientBufferNeeded);
}
else
Expand Down
42 changes: 26 additions & 16 deletions Unix/codec/mof/parser/types.c
Expand Up @@ -36,8 +36,11 @@
{ \
PTR = ((TYPE##A*)Batch_Get(state->batch, \
sizeof(TYPE##A) + sizeof(TYPE) * (SIZE))); \
PTR->data = (TYPE*)(PTR + 1); \
PTR->size = SIZE; \
if(PTR) \
{ \
PTR->data = (TYPE*)(PTR + 1); \
PTR->size = SIZE; \
} \
break; \
}

Expand Down Expand Up @@ -1596,24 +1599,31 @@ int InitializerToValue(
{
MI_InstanceA* arr;
arr = (MI_InstanceA*)Batch_Get(state->batch, sizeof(MI_InstanceA) + sizeof(MI_Instance*)*self->size);
arr->data = (MI_Instance**)(arr + 1);
arr->size = self->size;
for (i = 0; i < self->size; i++)
if(arr)
{
const MI_Char* alias = self->data[i].value.string;
const MI_InstanceAliasDecl *decl = FindInstanceAliasDecl(state, alias);
if (!decl)
arr->data = (MI_Instance**)(arr + 1);
arr->size = self->size;
for (i = 0; i < self->size; i++)
{
yyerrorf(state->errhandler, ID_UNDEFINED_INSTANCE_ALIAS,
"",
tcs(alias));
return -1;
const MI_Char* alias = self->data[i].value.string;
const MI_InstanceAliasDecl *decl = FindInstanceAliasDecl(state, alias);
if (!decl)
{
yyerrorf(state->errhandler, ID_UNDEFINED_INSTANCE_ALIAS,
"",
tcs(alias));
return -1;
}
arr->data[i] = decl->decl->instance;
decl->decl->refs++;
}
arr->data[i] = decl->decl->instance;
decl->decl->refs++;
*value = arr;
return 0;
}
*value = arr;
return 0;
else
{
return -1;
}
}
default:
return -1;
Expand Down
5 changes: 5 additions & 0 deletions Unix/disp/agentmgr.c
Expand Up @@ -860,6 +860,11 @@ static pid_t _SpawnAgentProcess(
close(fd);
}

/* Re-open fd 0,1,2. */
open("/dev/null", O_RDONLY);
open("/dev/null", O_RDWR);
open("/dev/null", O_RDWR);

/* prepare parameter:
socket fd to attach */
Snprintf(param_sock, sizeof(param_sock), "%d", (int)s);
Expand Down
14 changes: 10 additions & 4 deletions Unix/http/http.c
Expand Up @@ -853,8 +853,11 @@ _BuildHeader( Http_SR_SocketData* handler, int contentLen,
memcpy(bufp, HTTP_PROTOCOL_HEADER, HTTP_PROTOCOL_HEADER_LEN);
bufp += HTTP_PROTOCOL_HEADER_LEN;

memcpy(bufp, perrorcode, errorcode_strlen);
bufp += errorcode_strlen;
if(perrorcode)
{
memcpy(bufp, perrorcode, errorcode_strlen);
bufp += errorcode_strlen;
}

*bufp++ = ' ';

Expand All @@ -868,8 +871,11 @@ _BuildHeader( Http_SR_SocketData* handler, int contentLen,
memcpy(bufp, CONTENT_LENGTH_HEADER, CONTENT_LENGTH_HEADER_LEN);
bufp += CONTENT_LENGTH_HEADER_LEN;

memcpy(bufp, pcontent_len, content_len_strlen);
bufp += content_len_strlen;
if(pcontent_len)
{
memcpy(bufp, pcontent_len, content_len_strlen);
bufp += content_len_strlen;
}

memcpy(bufp, "\r\n", 2);
bufp += 2;
Expand Down
7 changes: 5 additions & 2 deletions Unix/http/httpclientauth.c
Expand Up @@ -2248,8 +2248,11 @@ HttpClient_NextAuthRequest(_In_ struct _HttpClient_SR_SocketData * self, _In_ co
strcpy(requestp, self->hostHeader);
requestp += strlen(self->hostHeader);

memcpy(requestp, auth_header, header_len);
requestp += header_len;
if(auth_header)
{
memcpy(requestp, auth_header, header_len);
requestp += header_len;
}

*requestp++ = '\r';
*requestp++ = '\n';
Expand Down
9 changes: 6 additions & 3 deletions Unix/mof/types.c
Expand Up @@ -41,8 +41,11 @@
{ \
PTR = ((TYPE##A*)MOF_Malloc(&state.heap, \
sizeof(TYPE##A) + sizeof(TYPE) * (SIZE))); \
PTR->data = (TYPE*)(PTR + 1); \
PTR->size = SIZE; \
if(PTR) \
{ \
PTR->data = (TYPE*)(PTR + 1); \
PTR->size = SIZE; \
} \
break; \
}

Expand Down Expand Up @@ -1748,7 +1751,7 @@ int InitializerToValue(
case MI_REAL64:
{
MI_Real64* p = MALLOC_T(MI_Real64, 1);
if (*p)
if (p)
{
*p = (MI_Real64)self->data->value.real;
*value = p;
Expand Down
5 changes: 5 additions & 0 deletions Unix/protocol/protocol.c
Expand Up @@ -1260,6 +1260,11 @@ static MI_Boolean _ProcessCreateAgentMsg(
close(fd);
}

/* Re-open fd 0,1,2. */
open("/dev/null", O_RDONLY);
open("/dev/null", O_RDWR);
open("/dev/null", O_RDWR);

execl(realAgentProgram,
realAgentProgram,
param_sock,
Expand Down
6 changes: 6 additions & 0 deletions Unix/server/server.c
Expand Up @@ -7,6 +7,7 @@
**==============================================================================
*/

#include <fcntl.h>
#include <stdlib.h>
#include <sock/sock.h>
#include <pal/dir.h>
Expand Down Expand Up @@ -142,6 +143,11 @@ static int _StartEngine(int argc, char** argv, char ** envp, const char *engineS
close(fd);
}

/* Re-open fd 0,1,2. */
open("/dev/null", O_RDONLY);
open("/dev/null", O_RDWR);
open("/dev/null", O_RDWR);

argv[argc-1] = int64_to_a(socketString, S_SOCKET_LENGTH, (long long)s[1], &size);
argv[argc-3] = int64_to_a(logfilefd, S_SOCKET_LENGTH, (long long)logfd, &size);

Expand Down
39 changes: 22 additions & 17 deletions Unix/xml/xml.c
Expand Up @@ -654,7 +654,10 @@ static void _ParseAttr(
}

/* Null-terminate the value */
*valueEnd = '\0';
if(valueEnd)
{
*valueEnd = '\0';
}
}

/* Skip spaces */
Expand Down Expand Up @@ -930,9 +933,12 @@ static void _ParseStartTag(
return;
}

item->name.namespaceUri = itemNS->uri;
item->name.namespaceUriSize = itemNS->uriSize;
item->name.namespaceId = itemNS->id;
if(itemNS)
{
item->name.namespaceUri = itemNS->uri;
item->name.namespaceUriSize = itemNS->uriSize;
item->name.namespaceId = itemNS->id;
}
}
}

Expand Down Expand Up @@ -1098,19 +1104,18 @@ static void _ParseEndTag(
*nameEnd = '\0';

ns = _FindNamespace(self, prefix);
if (ns)
{
if (self->status)
return;

/* Return element object */
elem->type = XML_END;
elem->data.data = name;
elem->data.size = nameEnd - name;
elem->data.namespaceUri = ns->uri;
elem->data.namespaceUriSize = ns->uriSize;
elem->data.namespaceId = ns->id;
}
if (ns == NULL || self->status)
return;

/* Return element object */
elem->type = XML_END;
elem->data.data = name;
elem->data.size = nameEnd - name;
elem->data.namespaceUri = ns->uri;
elem->data.namespaceUriSize = ns->uriSize;
elem->data.namespaceId = ns->id;

/* Match opening name */
{
/* Check for stack underflow */
Expand Down Expand Up @@ -1358,7 +1363,7 @@ static int _ParseCharData(
self->state = STATE_TAG;

/* Return character data element if non-empty */
if (end == start)
if (end == NULL || end == start)
return 0;

/* Prepare element */
Expand Down

0 comments on commit 9d143af

Please sign in to comment.