From f8f01bc67ba9e036540999efd44c698483b178cc Mon Sep 17 00:00:00 2001 From: gakamath Date: Fri, 17 Feb 2023 18:58:11 +0530 Subject: [PATCH 01/17] Setting hdl inside AUTHORIZATION macro as it is defined inside the macro --- Unix/http/httpauth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Unix/http/httpauth.c b/Unix/http/httpauth.c index 1f4cd8ce..3dfc3dfb 100644 --- a/Unix/http/httpauth.c +++ b/Unix/http/httpauth.c @@ -1629,8 +1629,8 @@ void Deauthorize(_In_ Http_SR_SocketData * handler) // 2do: Not clear what to do here // I'm going to procede anyway. } -#endif handler->pAuthContext = hdl; +#endif } if (handler->pVerifierCred) { From 73ce441e7f4c0904db6080164f680516a65b9cbb Mon Sep 17 00:00:00 2001 From: gakamath Date: Thu, 23 Feb 2023 15:57:19 +0530 Subject: [PATCH 02/17] Adding Explicit typecasts to address compiler warnings --- Unix/agent/agent.c | 4 +- Unix/base/class.c | 52 +++++------ Unix/base/helpers.c | 8 +- Unix/base/instance.c | 16 ++-- Unix/base/packing.c | 2 +- Unix/base/user.c | 2 +- Unix/codec/mof/parser/types.c | 14 +-- Unix/codec/mof/strings.c | 2 +- Unix/gen/QualifierDecls.cpp | 146 +++++++++++++++---------------- Unix/http/http.c | 6 +- Unix/http/httpauth.c | 2 +- Unix/http/httpclient.c | 4 +- Unix/http/httpclientauth.c | 8 +- Unix/mof/types.c | 8 +- Unix/omi_error/schema.c | 12 +-- Unix/providers/identify/schema.c | 4 +- Unix/provmgr/indicationSchema.c | 52 +++++------ Unix/server/servercommon.c | 2 +- Unix/sock/addr.c | 2 +- Unix/wsman/wsman.c | 7 +- 20 files changed, 176 insertions(+), 177 deletions(-) diff --git a/Unix/agent/agent.c b/Unix/agent/agent.c index 2b12c940..1a9c5e4d 100644 --- a/Unix/agent/agent.c +++ b/Unix/agent/agent.c @@ -330,7 +330,7 @@ static void GetCommandLineOptions(int* argc, const char* argv[]) scs(state.arg)); } - s_opts.idletimeout = x; + s_opts.idletimeout = (MI_Uint32)x; } else if (strcmp(state.opt, "--loglevel") == 0) { @@ -474,7 +474,7 @@ int agent_main(int argc, const char* argv[]) if (s_opts.idletimeout) { /* convert it to usec */ - s_data.provmgr.idleTimeoutUsec = s_opts.idletimeout * 1000000; + s_data.provmgr.idleTimeoutUsec = (MI_Uint64)s_opts.idletimeout * 1000000; trace_Agent_ChangingIdleTimeout(s_opts.idletimeout); } diff --git a/Unix/base/class.c b/Unix/base/class.c index 8e0431c7..1bc61c1a 100644 --- a/Unix/base/class.c +++ b/Unix/base/class.c @@ -290,7 +290,7 @@ MI_Result MI_CALL Class_GetElementAt( } if (referenceClass) { - *referenceClass = propertyDecl->className; + *referenceClass = (MI_Char*) propertyDecl->className; } if (qualifierSet) { @@ -366,12 +366,12 @@ MI_Result MI_CALL Class_GetElementAtExt( if(originClass) { - *originClass = propertyDecl->origin; + *originClass = (MI_Char*) propertyDecl->origin; } if(propagatorClass) { - *propagatorClass = propertyDecl->propagator; + *propagatorClass = (MI_Char*) propertyDecl->propagator; } return MI_RESULT_OK; @@ -489,12 +489,12 @@ MI_Result MI_CALL Class_GetMethodAtExt( if(originClass) { - *originClass = methodDecl->origin; + *originClass = (MI_Char*) methodDecl->origin; } if(propagatorClass) { - *propagatorClass = methodDecl->propagator; + *propagatorClass = (MI_Char*) methodDecl->propagator; } if(flags) @@ -680,7 +680,7 @@ MI_Result _ParameterSet_GetParameterAt( (*qualifierSet).reserved2 = (ptrdiff_t) parameterDecl[index]->qualifiers; if (referenceClass) { - *referenceClass = parameterDecl[index]->className; + *referenceClass = (MI_Char*) parameterDecl[index]->className; } return MI_RESULT_OK; } @@ -1649,7 +1649,7 @@ MI_PropertyDecl * Class_Clone_Property( MI_PropertyDecl *newProperty = Batch_Get(batch, sizeof(MI_PropertyDecl)); if (newProperty == NULL) { - return NULL; /* Returning NULL causes whole batch to destruct */ + return (MI_PropertyDecl*)NULL; /* Returning NULL causes whole batch to destruct */ } memset(newProperty, 0, sizeof(*newProperty)); newProperty->flags = property->flags; @@ -1657,14 +1657,14 @@ MI_PropertyDecl * Class_Clone_Property( newProperty->name = Batch_Tcsdup(batch, property->name); if (newProperty->name == NULL) { - return NULL; /* Returning NULL causes whole batch to destruct */ + return (MI_PropertyDecl*)NULL; /* Returning NULL causes whole batch to destruct */ } if (property->qualifiers && property->numQualifiers) { - newProperty->qualifiers = Class_Clone_Qualifiers(batch, property->qualifiers, property->numQualifiers); + newProperty->qualifiers = (MI_Qualifier**)Class_Clone_Qualifiers(batch, property->qualifiers, property->numQualifiers); if (newProperty->qualifiers == NULL) { - return NULL; /* Returning NULL causes whole batch to destruct */ + return (MI_PropertyDecl*)NULL; /* Returning NULL causes whole batch to destruct */ } newProperty->numQualifiers = property->numQualifiers; } @@ -1674,7 +1674,7 @@ MI_PropertyDecl * Class_Clone_Property( newProperty->className = Batch_Tcsdup(batch, property->className); /* embedded/reference stringly typed class name */ if (newProperty->className == NULL) { - return NULL; /* Returning NULL causes whole batch to destruct */ + return (MI_PropertyDecl*)NULL; /* Returning NULL causes whole batch to destruct */ } } newProperty->subscript = property->subscript; @@ -1684,7 +1684,7 @@ MI_PropertyDecl * Class_Clone_Property( newProperty->origin = Batch_Tcsdup(batch, property->origin); if (newProperty->origin == NULL) { - return NULL; /* Returning NULL causes whole batch to destruct */ + return (MI_PropertyDecl*)NULL; /* Returning NULL causes whole batch to destruct */ } } if (property->propagator) @@ -1692,7 +1692,7 @@ MI_PropertyDecl * Class_Clone_Property( newProperty->propagator = Batch_Tcsdup(batch, property->propagator); if (newProperty->propagator == NULL) { - return NULL; /* Returning NULL causes whole batch to destruct */ + return (MI_PropertyDecl*)NULL; /* Returning NULL causes whole batch to destruct */ } } if (((property->flags & MI_FLAG_NULL) != MI_FLAG_NULL) && property->value) @@ -1700,7 +1700,7 @@ MI_PropertyDecl * Class_Clone_Property( newProperty->value = Class_Clone_Value(batch, property->type, property->value); if (newProperty->value == NULL) { - return NULL; /* Returning NULL causes whole batch to destruct */ + return (MI_PropertyDecl*)NULL; /* Returning NULL causes whole batch to destruct */ } } else @@ -1761,7 +1761,7 @@ MI_ParameterDecl * Class_Clone_Parameter( } if (parameter->qualifiers && parameter->numQualifiers) { - newParameter->qualifiers = Class_Clone_Qualifiers(batch, parameter->qualifiers, parameter->numQualifiers); + newParameter->qualifiers = (MI_Qualifier**)Class_Clone_Qualifiers(batch, parameter->qualifiers, parameter->numQualifiers); if (newParameter->qualifiers == NULL) { return NULL; /* Returning NULL causes whole batch to destruct */ @@ -1823,7 +1823,7 @@ MI_MethodDecl * Class_Clone_Method( MI_MethodDecl *newMethod = Batch_Get(batch, sizeof(MI_MethodDecl)); if (newMethod == NULL) { - return NULL; /* Returning NULL causes whole batch to destruct */ + return (MI_MethodDecl *)NULL; /* Returning NULL causes whole batch to destruct */ } memset(newMethod, 0, sizeof(*newMethod)); newMethod->flags = method->flags; @@ -1831,23 +1831,23 @@ MI_MethodDecl * Class_Clone_Method( newMethod->name = Batch_Tcsdup(batch, method->name); if (newMethod->name == NULL) { - return NULL; /* Returning NULL causes whole batch to destruct */ + return (MI_MethodDecl *)NULL; /* Returning NULL causes whole batch to destruct */ } if (method->qualifiers && method->numQualifiers) { - newMethod->qualifiers = Class_Clone_Qualifiers(batch, method->qualifiers, method->numQualifiers); + newMethod->qualifiers = (struct _MI_Qualifier**)Class_Clone_Qualifiers(batch, method->qualifiers, method->numQualifiers); if (newMethod->qualifiers == NULL) { - return NULL; /* Returning NULL causes whole batch to destruct */ + return (MI_MethodDecl *)NULL; /* Returning NULL causes whole batch to destruct */ } newMethod->numQualifiers = method->numQualifiers; } if (method->parameters && method->numParameters) { - newMethod->parameters = Class_Clone_Parameters(batch, method->parameters, method->numParameters, className); + newMethod->parameters = (struct _MI_ParameterDecl**)Class_Clone_Parameters(batch, method->parameters, method->numParameters, className); if (newMethod->parameters == NULL) { - return NULL; /* Returning NULL causes whole batch to destruct */ + return (MI_MethodDecl *)NULL; /* Returning NULL causes whole batch to destruct */ } newMethod->numParameters = method->numParameters; } @@ -1858,7 +1858,7 @@ MI_MethodDecl * Class_Clone_Method( newMethod->origin = Batch_Tcsdup(batch, method->origin); if (newMethod->origin == NULL) { - return NULL; /* Returning NULL causes whole batch to destruct */ + return (MI_MethodDecl *)NULL; /* Returning NULL causes whole batch to destruct */ } } if (method->propagator) @@ -1866,7 +1866,7 @@ MI_MethodDecl * Class_Clone_Method( newMethod->propagator = Batch_Tcsdup(batch, method->propagator); if (newMethod->propagator == NULL) { - return NULL; /* Returning NULL causes whole batch to destruct */ + return (MI_MethodDecl *)NULL; /* Returning NULL causes whole batch to destruct */ } } /* Leave owning schema NULL otherwise we would need to potentially clone that and every other class in there */ @@ -1925,7 +1925,7 @@ MI_ClassDecl* Class_Clone_ClassDecl( } if (classDecl->qualifiers && classDecl->numQualifiers) { - newClassDecl->qualifiers = Class_Clone_Qualifiers(batch, classDecl->qualifiers, classDecl->numQualifiers); + newClassDecl->qualifiers = (struct _MI_Qualifier**)Class_Clone_Qualifiers(batch, classDecl->qualifiers, classDecl->numQualifiers); if (newClassDecl->qualifiers == NULL) { return NULL; /* Returning NULL causes whole batch to destruct */ @@ -1934,7 +1934,7 @@ MI_ClassDecl* Class_Clone_ClassDecl( } if (classDecl->properties && classDecl->numProperties) { - newClassDecl->properties = Class_Clone_Properties(batch, classDecl->properties, classDecl->numProperties); + newClassDecl->properties = (struct _MI_PropertyDecl**)Class_Clone_Properties(batch, classDecl->properties, classDecl->numProperties); if (newClassDecl->properties == NULL) { return NULL; /* Returning NULL causes whole batch to destruct */ @@ -1962,7 +1962,7 @@ MI_ClassDecl* Class_Clone_ClassDecl( } if (classDecl->methods && classDecl->numMethods) { - newClassDecl->methods = Class_Clone_Methods(batch, classDecl->methods, classDecl->numMethods, classDecl->name); + newClassDecl->methods = (struct _MI_MethodDecl**)Class_Clone_Methods(batch, classDecl->methods, classDecl->numMethods, classDecl->name); if (newClassDecl->methods == NULL) { return NULL; /* Returning NULL causes whole batch to destruct */ diff --git a/Unix/base/helpers.c b/Unix/base/helpers.c index 6a720574..abdc3512 100644 --- a/Unix/base/helpers.c +++ b/Unix/base/helpers.c @@ -969,10 +969,10 @@ static int _Base64DecCallback( start = *str; { - unsigned char b1 = (totalSize & 0xFF000000) >> 24; - unsigned char b2 = (totalSize & 0x00FF0000) >> 16; - unsigned char b3 = (totalSize & 0x0000FF00) >> 8; - unsigned char b4 = (totalSize & 0x000000FF); + unsigned char b1 = (unsigned char)((totalSize & 0xFF000000) >> 24); + unsigned char b2 = (unsigned char)((totalSize & 0x00FF0000) >> 16); + unsigned char b3 = (unsigned char)((totalSize & 0x0000FF00) >> 8); + unsigned char b4 = (unsigned char)((totalSize & 0x000000FF)); (*str)[0] = b1; (*str)[1] = b2; (*str)[2] = b3; diff --git a/Unix/base/instance.c b/Unix/base/instance.c index bf6e8d30..9786a86e 100644 --- a/Unix/base/instance.c +++ b/Unix/base/instance.c @@ -499,7 +499,7 @@ MI_Result MI_CALL Instance_Construct( if (result != MI_RESULT_OK) return result; - self->classDecl = newClass->classDecl; + self->classDecl = (MI_ClassDecl*)newClass->classDecl; } else if (cd->flags & (MI_FLAG_CLASS|MI_FLAG_ASSOCIATION|MI_FLAG_INDICATION)) { @@ -1076,7 +1076,7 @@ MI_Result MI_CALL Instance_Clone( MI_Result result = MI_Class_Clone(self->classDecl->owningClass, &clonedClass); if (result != MI_RESULT_OK) MI_RETURN(result); - inst->classDecl = clonedClass->classDecl; + inst->classDecl = (MI_ClassDecl*)clonedClass->classDecl; } else//We had better do a hard clone { @@ -1135,7 +1135,7 @@ MI_Result MI_CALL Instance_SetClassName( MI_RETURN(MI_RESULT_INVALID_PARAMETER); /* Save old className */ - oldClassName = self->classDecl->name; + oldClassName = (ZChar*)self->classDecl->name; /* Set new className */ { @@ -1459,13 +1459,13 @@ MI_Result MI_CALL __MI_Instance_Destruct( for (i = 0; i < self->classDecl->numProperties; i++) { MI_PropertyDecl* pd = self->classDecl->properties[i]; - BFree(batch, pd->name, CALLSITE); - BFree(batch, pd, CALLSITE); + BFree(batch, (void *)pd->name, CALLSITE); + BFree(batch, (void *)pd, CALLSITE); } - BFree(batch, self->classDecl->name, CALLSITE); - BFree(batch, self->classDecl->properties, CALLSITE); - BFree(batch, self->classDecl, CALLSITE); + BFree(batch, (void *)self->classDecl->name, CALLSITE); + BFree(batch, (void *)self->classDecl->properties, CALLSITE); + BFree(batch, (void *)self->classDecl, CALLSITE); if ((void*)self != (void*)self_) _FreeInstance(batch, self); diff --git a/Unix/base/packing.c b/Unix/base/packing.c index 0a850c82..f98cdc2c 100644 --- a/Unix/base/packing.c +++ b/Unix/base/packing.c @@ -461,7 +461,7 @@ MI_Result Instance_Pack( /* Pack the flags */ MI_RETURN_ERR(Buf_PackU32(buf, pd->flags)); - pName = pd->name; + pName = (MI_Char*)pd->name; if ((pd->flags & MI_FLAG_PARAMETER) && (pd->flags & MI_FLAG_OUT)) { if (pName && pName[0] == ZT('M') && Tcscmp(pName, ZT("MIReturn"))== 0) diff --git a/Unix/base/user.c b/Unix/base/user.c index ae047399..131edc27 100644 --- a/Unix/base/user.c +++ b/Unix/base/user.c @@ -381,7 +381,7 @@ int GetUserGidByUid(uid_t uid, gid_t* gid) /* user name */ char name[USERNAME_SIZE]; - if (0 != GetUserName(uid, name)) + if (0 != GetUserName((LPSTR)uid, (LPDWORD)name)) return -1; return LookupUser(name, &uid, gid); diff --git a/Unix/codec/mof/parser/types.c b/Unix/codec/mof/parser/types.c index d93b4747..8bd90506 100644 --- a/Unix/codec/mof/parser/types.c +++ b/Unix/codec/mof/parser/types.c @@ -1141,7 +1141,7 @@ static int _PromoteValue( if (destpropertydecl->className) { *embeddedpropertyError = MI_TRUE; - return _IsInstanceOfClass(state, inst, destpropertydecl->className); + return _IsInstanceOfClass(state, inst, (MI_Char *)destpropertydecl->className); } return 0; } @@ -1155,7 +1155,7 @@ static int _PromoteValue( case MI_REFERENCEA: { const MI_InstanceA * insta = *(const MI_InstanceA**)value; - MI_Char *destclassname = destpropertydecl->className; + MI_Char *destclassname = (MI_Char *)destpropertydecl->className; if (destclassname) { *embeddedpropertyError = MI_TRUE; @@ -3003,11 +3003,11 @@ void MOF_PrintInstanceDecl( /* properties */ if (self->properties) - _PrintProperties(self->properties, self->numProperties, level, file); + _PrintProperties(self->properties, (size_t)self->numProperties, level, file); /* qualifiers */ if (self->qualifiers) - _PrintQualifiers(self->qualifiers, self->numQualifiers, level, file); + _PrintQualifiers(self->qualifiers, (size_t)self->numQualifiers, level, file); /* Footer */ level--; @@ -4126,7 +4126,7 @@ int FinalizeInstance( /* For each instance property */ for (i = 0; i < id->numProperties; i++) { - MI_PropertyDecl* p = id->properties[i]; + MI_PropertyDecl* p = (MI_PropertyDecl* )id->properties[i]; MI_PropertyDecl* q = NULL; /* Find the class property with the same name */ @@ -4276,9 +4276,9 @@ int FinalizeInstance( /* For each instance property */ for (i = 0; i < id->numProperties; i++) { - MI_PropertyDecl* p = id->properties[i]; + MI_PropertyDecl* p = (MI_PropertyDecl* )id->properties[i]; MI_Value *value = (MI_Value*)(p->value); - if (ProcessProperty(state->parser->param.schemacheck, p->name, (const MI_Char**) ignorePropertyList, ignorePropertyCount)) + if (ProcessProperty(state->parser->param.schemacheck, (MI_Char*)p->name, (const MI_Char**) ignorePropertyList, ignorePropertyCount)) { if (validClassDecl) { diff --git a/Unix/codec/mof/strings.c b/Unix/codec/mof/strings.c index 409d5bde..0246cd6c 100644 --- a/Unix/codec/mof/strings.c +++ b/Unix/codec/mof/strings.c @@ -180,7 +180,7 @@ MI_Char* GetString(MI_Uint32 id) { if (id < cSTRSLength) { - return cSTRS[id]; + return (MI_Char*)cSTRS[id]; } return NULL; } diff --git a/Unix/gen/QualifierDecls.cpp b/Unix/gen/QualifierDecls.cpp index eb490f42..7188a21c 100644 --- a/Unix/gen/QualifierDecls.cpp +++ b/Unix/gen/QualifierDecls.cpp @@ -24,7 +24,7 @@ static MI_Boolean Abstract_qual_decl_value = 0; static MI_QualifierDecl Abstract_qual_decl = { - (char*)"Abstract", /* name */ + (MI_Char*)"Abstract", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_ASSOCIATION|MI_FLAG_CLASS|MI_FLAG_INDICATION, /* scope */ @@ -36,7 +36,7 @@ static MI_Boolean Aggregate_qual_decl_value = 0; static MI_QualifierDecl Aggregate_qual_decl = { - (char*)"Aggregate", /* name */ + (MI_Char*)"Aggregate", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_REFERENCE, /* scope */ @@ -48,7 +48,7 @@ static MI_Boolean Aggregation_qual_decl_value = 0; static MI_QualifierDecl Aggregation_qual_decl = { - (char*)"Aggregation", /* name */ + (MI_Char*)"Aggregation", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_ASSOCIATION, /* scope */ @@ -58,7 +58,7 @@ static MI_QualifierDecl Aggregation_qual_decl = static MI_QualifierDecl Alias_qual_decl = { - (char*)"Alias", /* name */ + (MI_Char*)"Alias", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PROPERTY|MI_FLAG_REFERENCE, /* scope */ @@ -66,11 +66,11 @@ static MI_QualifierDecl Alias_qual_decl = NULL, /* value */ }; -static const MI_Char* ArrayType_qual_decl_value = "Bag"; +static const MI_Char* ArrayType_qual_decl_value = (MI_Char *)"Bag"; static MI_QualifierDecl ArrayType_qual_decl = { - (char*)"ArrayType", /* name */ + (MI_Char*)"ArrayType", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_PARAMETER|MI_FLAG_PROPERTY, /* scope */ @@ -82,7 +82,7 @@ static MI_Boolean Association_qual_decl_value = 0; static MI_QualifierDecl Association_qual_decl = { - (char*)"Association", /* name */ + (MI_Char*)"Association", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_ASSOCIATION, /* scope */ @@ -92,7 +92,7 @@ static MI_QualifierDecl Association_qual_decl = static MI_QualifierDecl BitMap_qual_decl = { - (char*)"BitMap", /* name */ + (MI_Char*)"BitMap", /* name */ MI_STRINGA, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY, /* scope */ @@ -102,7 +102,7 @@ static MI_QualifierDecl BitMap_qual_decl = static MI_QualifierDecl BitValues_qual_decl = { - (char*)"BitValues", /* name */ + (MI_Char*)"BitValues", /* name */ MI_STRINGA, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY, /* scope */ @@ -112,7 +112,7 @@ static MI_QualifierDecl BitValues_qual_decl = static MI_QualifierDecl ClassConstraint_qual_decl = { - (char*)"ClassConstraint", /* name */ + (MI_Char*)"ClassConstraint", /* name */ MI_STRINGA, /* type */ 0, /* subscript */ MI_FLAG_ASSOCIATION|MI_FLAG_CLASS|MI_FLAG_INDICATION, /* scope */ @@ -124,7 +124,7 @@ static MI_Boolean Composition_qual_decl_value = 0; static MI_QualifierDecl Composition_qual_decl = { - (char*)"Composition", /* name */ + (MI_Char*)"Composition", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_ASSOCIATION, /* scope */ @@ -134,7 +134,7 @@ static MI_QualifierDecl Composition_qual_decl = static MI_QualifierDecl Correlatable_qual_decl = { - (char*)"Correlatable", /* name */ + (MI_Char*)"Correlatable", /* name */ MI_STRINGA, /* type */ 0, /* subscript */ MI_FLAG_PROPERTY, /* scope */ @@ -146,7 +146,7 @@ static MI_Boolean Counter_qual_decl_value = 0; static MI_QualifierDecl Counter_qual_decl = { - (char*)"Counter", /* name */ + (MI_Char*)"Counter", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY, /* scope */ @@ -158,7 +158,7 @@ static MI_Boolean DN_qual_decl_value = 0; static MI_QualifierDecl DN_qual_decl = { - (char*)"DN", /* name */ + (MI_Char*)"DN", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY, /* scope */ @@ -170,7 +170,7 @@ static MI_Boolean Delete_qual_decl_value = 0; static MI_QualifierDecl Delete_qual_decl = { - (char*)"Delete", /* name */ + (MI_Char*)"Delete", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_ASSOCIATION|MI_FLAG_REFERENCE, /* scope */ @@ -180,7 +180,7 @@ static MI_QualifierDecl Delete_qual_decl = static MI_QualifierDecl Deprecated_qual_decl = { - (char*)"Deprecated", /* name */ + (MI_Char*)"Deprecated", /* name */ MI_STRINGA, /* type */ 0, /* subscript */ MI_FLAG_ANY, /* scope */ @@ -190,7 +190,7 @@ static MI_QualifierDecl Deprecated_qual_decl = static MI_QualifierDecl Description_qual_decl = { - (char*)"Description", /* name */ + (MI_Char*)"Description", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_ANY, /* scope */ @@ -200,7 +200,7 @@ static MI_QualifierDecl Description_qual_decl = static MI_QualifierDecl DisplayDescription_qual_decl = { - (char*)"DisplayDescription", /* name */ + (MI_Char*)"DisplayDescription", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_ANY, /* scope */ @@ -210,7 +210,7 @@ static MI_QualifierDecl DisplayDescription_qual_decl = static MI_QualifierDecl DisplayName_qual_decl = { - (char*)"DisplayName", /* name */ + (MI_Char*)"DisplayName", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_ANY, /* scope */ @@ -220,7 +220,7 @@ static MI_QualifierDecl DisplayName_qual_decl = static MI_QualifierDecl EmbeddedInstance_qual_decl = { - (char*)"EmbeddedInstance", /* name */ + (MI_Char*)"EmbeddedInstance", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY, /* scope */ @@ -232,7 +232,7 @@ static MI_Boolean EmbeddedObject_qual_decl_value = 0; static MI_QualifierDecl EmbeddedObject_qual_decl = { - (char*)"EmbeddedObject", /* name */ + (MI_Char*)"EmbeddedObject", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY, /* scope */ @@ -244,7 +244,7 @@ static MI_Boolean Exception_qual_decl_value = 0; static MI_QualifierDecl Exception_qual_decl = { - (char*)"Exception", /* name */ + (MI_Char*)"Exception", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_CLASS|MI_FLAG_INDICATION, /* scope */ @@ -256,7 +256,7 @@ static MI_Boolean Expensive_qual_decl_value = 0; static MI_QualifierDecl Expensive_qual_decl = { - (char*)"Expensive", /* name */ + (MI_Char*)"Expensive", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_ANY, /* scope */ @@ -268,7 +268,7 @@ static MI_Boolean Experimental_qual_decl_value = 0; static MI_QualifierDecl Experimental_qual_decl = { - (char*)"Experimental", /* name */ + (MI_Char*)"Experimental", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_ANY, /* scope */ @@ -280,7 +280,7 @@ static MI_Boolean Gauge_qual_decl_value = 0; static MI_QualifierDecl Gauge_qual_decl = { - (char*)"Gauge", /* name */ + (MI_Char*)"Gauge", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY, /* scope */ @@ -292,7 +292,7 @@ static MI_Boolean Ifdeleted_qual_decl_value = 0; static MI_QualifierDecl Ifdeleted_qual_decl = { - (char*)"Ifdeleted", /* name */ + (MI_Char*)"Ifdeleted", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_ASSOCIATION|MI_FLAG_REFERENCE, /* scope */ @@ -304,7 +304,7 @@ static MI_Boolean In_qual_decl_value = 1; static MI_QualifierDecl In_qual_decl = { - (char*)"In", /* name */ + (MI_Char*)"In", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_PARAMETER, /* scope */ @@ -316,7 +316,7 @@ static MI_Boolean Indication_qual_decl_value = 0; static MI_QualifierDecl Indication_qual_decl = { - (char*)"Indication", /* name */ + (MI_Char*)"Indication", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_CLASS|MI_FLAG_INDICATION, /* scope */ @@ -328,7 +328,7 @@ static MI_Boolean Invisible_qual_decl_value = 0; static MI_QualifierDecl Invisible_qual_decl = { - (char*)"Invisible", /* name */ + (MI_Char*)"Invisible", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_ASSOCIATION|MI_FLAG_CLASS|MI_FLAG_METHOD|MI_FLAG_PROPERTY|MI_FLAG_REFERENCE, /* scope */ @@ -340,7 +340,7 @@ static MI_Boolean IsPUnit_qual_decl_value = 0; static MI_QualifierDecl IsPUnit_qual_decl = { - (char*)"IsPUnit", /* name */ + (MI_Char*)"IsPUnit", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY, /* scope */ @@ -352,7 +352,7 @@ static MI_Boolean Key_qual_decl_value = 0; static MI_QualifierDecl Key_qual_decl = { - (char*)"Key", /* name */ + (MI_Char*)"Key", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_PROPERTY|MI_FLAG_REFERENCE, /* scope */ @@ -364,7 +364,7 @@ static MI_Boolean Large_qual_decl_value = 0; static MI_QualifierDecl Large_qual_decl = { - (char*)"Large", /* name */ + (MI_Char*)"Large", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_CLASS|MI_FLAG_PROPERTY, /* scope */ @@ -374,7 +374,7 @@ static MI_QualifierDecl Large_qual_decl = static MI_QualifierDecl MappingStrings_qual_decl = { - (char*)"MappingStrings", /* name */ + (MI_Char*)"MappingStrings", /* name */ MI_STRINGA, /* type */ 0, /* subscript */ MI_FLAG_ANY, /* scope */ @@ -384,7 +384,7 @@ static MI_QualifierDecl MappingStrings_qual_decl = static MI_QualifierDecl Max_qual_decl = { - (char*)"Max", /* name */ + (MI_Char*)"Max", /* name */ MI_UINT32, /* type */ 0, /* subscript */ MI_FLAG_REFERENCE, /* scope */ @@ -394,7 +394,7 @@ static MI_QualifierDecl Max_qual_decl = static MI_QualifierDecl MaxLen_qual_decl = { - (char*)"MaxLen", /* name */ + (MI_Char*)"MaxLen", /* name */ MI_UINT32, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY, /* scope */ @@ -404,7 +404,7 @@ static MI_QualifierDecl MaxLen_qual_decl = static MI_QualifierDecl MaxValue_qual_decl = { - (char*)"MaxValue", /* name */ + (MI_Char*)"MaxValue", /* name */ MI_SINT64, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY, /* scope */ @@ -414,7 +414,7 @@ static MI_QualifierDecl MaxValue_qual_decl = static MI_QualifierDecl MethodConstraint_qual_decl = { - (char*)"MethodConstraint", /* name */ + (MI_Char*)"MethodConstraint", /* name */ MI_STRINGA, /* type */ 0, /* subscript */ MI_FLAG_METHOD, /* scope */ @@ -426,7 +426,7 @@ static MI_Uint32 Min_qual_decl_value = 0; static MI_QualifierDecl Min_qual_decl = { - (char*)"Min", /* name */ + (MI_Char*)"Min", /* name */ MI_UINT32, /* type */ 0, /* subscript */ MI_FLAG_REFERENCE, /* scope */ @@ -438,7 +438,7 @@ static MI_Uint32 MinLen_qual_decl_value = 0; static MI_QualifierDecl MinLen_qual_decl = { - (char*)"MinLen", /* name */ + (MI_Char*)"MinLen", /* name */ MI_UINT32, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY, /* scope */ @@ -448,7 +448,7 @@ static MI_QualifierDecl MinLen_qual_decl = static MI_QualifierDecl MinValue_qual_decl = { - (char*)"MinValue", /* name */ + (MI_Char*)"MinValue", /* name */ MI_SINT64, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY, /* scope */ @@ -458,7 +458,7 @@ static MI_QualifierDecl MinValue_qual_decl = static MI_QualifierDecl ModelCorrespondence_qual_decl = { - (char*)"ModelCorrespondence", /* name */ + (MI_Char*)"ModelCorrespondence", /* name */ MI_STRINGA, /* type */ 0, /* subscript */ MI_FLAG_ANY, /* scope */ @@ -468,7 +468,7 @@ static MI_QualifierDecl ModelCorrespondence_qual_decl = static MI_QualifierDecl Nonlocal_qual_decl = { - (char*)"Nonlocal", /* name */ + (MI_Char*)"Nonlocal", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_REFERENCE, /* scope */ @@ -478,7 +478,7 @@ static MI_QualifierDecl Nonlocal_qual_decl = static MI_QualifierDecl NonlocalType_qual_decl = { - (char*)"NonlocalType", /* name */ + (MI_Char*)"NonlocalType", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_REFERENCE, /* scope */ @@ -488,7 +488,7 @@ static MI_QualifierDecl NonlocalType_qual_decl = static MI_QualifierDecl NullValue_qual_decl = { - (char*)"NullValue", /* name */ + (MI_Char*)"NullValue", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_PROPERTY, /* scope */ @@ -500,7 +500,7 @@ static MI_Boolean Octetstring_qual_decl_value = 0; static MI_QualifierDecl Octetstring_qual_decl = { - (char*)"Octetstring", /* name */ + (MI_Char*)"Octetstring", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY, /* scope */ @@ -512,7 +512,7 @@ static MI_Boolean Out_qual_decl_value = 0; static MI_QualifierDecl Out_qual_decl = { - (char*)"Out", /* name */ + (MI_Char*)"Out", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_PARAMETER, /* scope */ @@ -522,7 +522,7 @@ static MI_QualifierDecl Out_qual_decl = static MI_QualifierDecl Override_qual_decl = { - (char*)"Override", /* name */ + (MI_Char*)"Override", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PROPERTY|MI_FLAG_REFERENCE, /* scope */ @@ -532,7 +532,7 @@ static MI_QualifierDecl Override_qual_decl = static MI_QualifierDecl PUnit_qual_decl = { - (char*)"PUnit", /* name */ + (MI_Char*)"PUnit", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY, /* scope */ @@ -542,7 +542,7 @@ static MI_QualifierDecl PUnit_qual_decl = static MI_QualifierDecl Propagated_qual_decl = { - (char*)"Propagated", /* name */ + (MI_Char*)"Propagated", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_PROPERTY, /* scope */ @@ -552,7 +552,7 @@ static MI_QualifierDecl Propagated_qual_decl = static MI_QualifierDecl PropertyConstraint_qual_decl = { - (char*)"PropertyConstraint", /* name */ + (MI_Char*)"PropertyConstraint", /* name */ MI_STRINGA, /* type */ 0, /* subscript */ MI_FLAG_PROPERTY|MI_FLAG_REFERENCE, /* scope */ @@ -560,11 +560,11 @@ static MI_QualifierDecl PropertyConstraint_qual_decl = NULL, /* value */ }; -static const MI_Char* PropertyUsage_qual_decl_value = "CurrentContext"; +static const MI_Char* PropertyUsage_qual_decl_value = (MI_Char*)"CurrentContext"; static MI_QualifierDecl PropertyUsage_qual_decl = { - (char*)"PropertyUsage", /* name */ + (MI_Char*)"PropertyUsage", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_PROPERTY, /* scope */ @@ -574,7 +574,7 @@ static MI_QualifierDecl PropertyUsage_qual_decl = static MI_QualifierDecl Provider_qual_decl = { - (char*)"Provider", /* name */ + (MI_Char*)"Provider", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_ANY, /* scope */ @@ -586,7 +586,7 @@ static MI_Boolean Read_qual_decl_value = 1; static MI_QualifierDecl Read_qual_decl = { - (char*)"Read", /* name */ + (MI_Char*)"Read", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_PROPERTY, /* scope */ @@ -598,7 +598,7 @@ static MI_Boolean Required_qual_decl_value = 0; static MI_QualifierDecl Required_qual_decl = { - (char*)"Required", /* name */ + (MI_Char*)"Required", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY|MI_FLAG_REFERENCE, /* scope */ @@ -608,7 +608,7 @@ static MI_QualifierDecl Required_qual_decl = static MI_QualifierDecl Revision_qual_decl = { - (char*)"Revision", /* name */ + (MI_Char*)"Revision", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_ASSOCIATION|MI_FLAG_CLASS|MI_FLAG_INDICATION, /* scope */ @@ -618,7 +618,7 @@ static MI_QualifierDecl Revision_qual_decl = static MI_QualifierDecl Schema_qual_decl = { - (char*)"Schema", /* name */ + (MI_Char*)"Schema", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PROPERTY, /* scope */ @@ -628,7 +628,7 @@ static MI_QualifierDecl Schema_qual_decl = static MI_QualifierDecl Source_qual_decl = { - (char*)"Source", /* name */ + (MI_Char*)"Source", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_ASSOCIATION|MI_FLAG_CLASS|MI_FLAG_INDICATION, /* scope */ @@ -638,7 +638,7 @@ static MI_QualifierDecl Source_qual_decl = static MI_QualifierDecl SourceType_qual_decl = { - (char*)"SourceType", /* name */ + (MI_Char*)"SourceType", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_ASSOCIATION|MI_FLAG_CLASS|MI_FLAG_INDICATION|MI_FLAG_REFERENCE, /* scope */ @@ -650,7 +650,7 @@ static MI_Boolean Static_qual_decl_value = 0; static MI_QualifierDecl Static_qual_decl = { - (char*)"Static", /* name */ + (MI_Char*)"Static", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PROPERTY, /* scope */ @@ -660,7 +660,7 @@ static MI_QualifierDecl Static_qual_decl = static MI_QualifierDecl Syntax_qual_decl = { - (char*)"Syntax", /* name */ + (MI_Char*)"Syntax", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY|MI_FLAG_REFERENCE, /* scope */ @@ -670,7 +670,7 @@ static MI_QualifierDecl Syntax_qual_decl = static MI_QualifierDecl SyntaxType_qual_decl = { - (char*)"SyntaxType", /* name */ + (MI_Char*)"SyntaxType", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY|MI_FLAG_REFERENCE, /* scope */ @@ -682,7 +682,7 @@ static MI_Boolean Terminal_qual_decl_value = 0; static MI_QualifierDecl Terminal_qual_decl = { - (char*)"Terminal", /* name */ + (MI_Char*)"Terminal", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_ASSOCIATION|MI_FLAG_CLASS|MI_FLAG_INDICATION, /* scope */ @@ -692,7 +692,7 @@ static MI_QualifierDecl Terminal_qual_decl = static MI_QualifierDecl TriggerType_qual_decl = { - (char*)"TriggerType", /* name */ + (MI_Char*)"TriggerType", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_ASSOCIATION|MI_FLAG_CLASS|MI_FLAG_INDICATION|MI_FLAG_METHOD|MI_FLAG_PROPERTY|MI_FLAG_REFERENCE, /* scope */ @@ -702,7 +702,7 @@ static MI_QualifierDecl TriggerType_qual_decl = static MI_QualifierDecl UMLPackagePath_qual_decl = { - (char*)"UMLPackagePath", /* name */ + (MI_Char*)"UMLPackagePath", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_ASSOCIATION|MI_FLAG_CLASS|MI_FLAG_INDICATION, /* scope */ @@ -712,7 +712,7 @@ static MI_QualifierDecl UMLPackagePath_qual_decl = static MI_QualifierDecl Units_qual_decl = { - (char*)"Units", /* name */ + (MI_Char*)"Units", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY, /* scope */ @@ -722,7 +722,7 @@ static MI_QualifierDecl Units_qual_decl = static MI_QualifierDecl UnknownValues_qual_decl = { - (char*)"UnknownValues", /* name */ + (MI_Char*)"UnknownValues", /* name */ MI_STRINGA, /* type */ 0, /* subscript */ MI_FLAG_PROPERTY, /* scope */ @@ -732,7 +732,7 @@ static MI_QualifierDecl UnknownValues_qual_decl = static MI_QualifierDecl UnsupportedValues_qual_decl = { - (char*)"UnsupportedValues", /* name */ + (MI_Char*)"UnsupportedValues", /* name */ MI_STRINGA, /* type */ 0, /* subscript */ MI_FLAG_PROPERTY, /* scope */ @@ -742,7 +742,7 @@ static MI_QualifierDecl UnsupportedValues_qual_decl = static MI_QualifierDecl ValueMap_qual_decl = { - (char*)"ValueMap", /* name */ + (MI_Char*)"ValueMap", /* name */ MI_STRINGA, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY, /* scope */ @@ -752,7 +752,7 @@ static MI_QualifierDecl ValueMap_qual_decl = static MI_QualifierDecl Values_qual_decl = { - (char*)"Values", /* name */ + (MI_Char*)"Values", /* name */ MI_STRINGA, /* type */ 0, /* subscript */ MI_FLAG_METHOD|MI_FLAG_PARAMETER|MI_FLAG_PROPERTY, /* scope */ @@ -762,7 +762,7 @@ static MI_QualifierDecl Values_qual_decl = static MI_QualifierDecl Version_qual_decl = { - (char*)"Version", /* name */ + (MI_Char*)"Version", /* name */ MI_STRING, /* type */ 0, /* subscript */ MI_FLAG_ASSOCIATION|MI_FLAG_CLASS|MI_FLAG_INDICATION, /* scope */ @@ -774,7 +774,7 @@ static MI_Boolean Weak_qual_decl_value = 0; static MI_QualifierDecl Weak_qual_decl = { - (char*)"Weak", /* name */ + (MI_Char*)"Weak", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_REFERENCE, /* scope */ @@ -786,7 +786,7 @@ static MI_Boolean Write_qual_decl_value = 0; static MI_QualifierDecl Write_qual_decl = { - (char*)"Write", /* name */ + (MI_Char*)"Write", /* name */ MI_BOOLEAN, /* type */ 0, /* subscript */ MI_FLAG_PROPERTY, /* scope */ diff --git a/Unix/http/http.c b/Unix/http/http.c index 4a481bfa..70bccd60 100644 --- a/Unix/http/http.c +++ b/Unix/http/http.c @@ -992,9 +992,9 @@ static Http_CallbackResult _WriteHeader( Http_SR_SocketData* handler) { GetTimeStamp(startTime); _WriteTraceFile(ID_HTTPSENDTRACEFILE, &startTime, strlen(startTime)); - _WriteTraceFile(ID_HTTPSENDTRACEFILE, &before_encrypt, sizeof(before_encrypt)); + _WriteTraceFile(ID_HTTPSENDTRACEFILE, (void *) &before_encrypt, sizeof(before_encrypt)); _WriteTraceFile(ID_HTTPSENDTRACEFILE, (char *)(pOldPage+1), pOldPage->u.s.size); - _WriteTraceFile(ID_HTTPSENDTRACEFILE, &before_encrypt_end, sizeof(before_encrypt_end)); + _WriteTraceFile(ID_HTTPSENDTRACEFILE, (void *) &before_encrypt_end, sizeof(before_encrypt_end)); } } @@ -1094,7 +1094,7 @@ static Http_CallbackResult _WriteData( buf_size = handler->sendPage->u.s.size - handler->sentSize; sent = 0; - r = _Sock_Write(handler, buf, buf_size, &sent); + r = _Sock_Write(handler, (void*)(buf), buf_size, &sent); if ( r == MI_RESULT_OK && 0 == sent ) return PRT_RETURN_FALSE; /* conection closed */ diff --git a/Unix/http/httpauth.c b/Unix/http/httpauth.c index 3dfc3dfb..c08c0147 100644 --- a/Unix/http/httpauth.c +++ b/Unix/http/httpauth.c @@ -875,7 +875,7 @@ static MI_Boolean _WriteAuthResponse(Http_SR_SocketData * handler, const char *p total_sent += sent; } - while (total_sent < responseLen); + while ((int)total_sent < responseLen); if (FORCE_TRACING || ((total_sent > 0) && handler->enableTracing)) { diff --git a/Unix/http/httpclient.c b/Unix/http/httpclient.c index 81ee562a..5d9dd67e 100644 --- a/Unix/http/httpclient.c +++ b/Unix/http/httpclient.c @@ -3082,13 +3082,13 @@ MI_Result HttpClient_StartRequest( self->connector->authType = AUTH_METHOD_BYPASS; } - rtnval = HttpClient_StartRequestV2(self, verb, uri, content_type, auth_header, headers, data, NULL ); + rtnval = HttpClient_StartRequestV2(self, verb, uri, content_type, auth_header, (HttpClientRequestHeaders*)headers, data, (Probable_Cause_Data **)NULL); if (tmp_headers != NULL) { // When extra_headers are used properly, please reassess whether this PAL_Free belongs here. // This exists for now to prevent a memory leak. - PAL_Free(tmp_headers); + PAL_Free((void *)tmp_headers); } return rtnval; diff --git a/Unix/http/httpclientauth.c b/Unix/http/httpclientauth.c index cab874f2..22d72503 100644 --- a/Unix/http/httpclientauth.c +++ b/Unix/http/httpclientauth.c @@ -961,7 +961,7 @@ static void _ReportError(HttpClient_SR_SocketData * self, const char *msg, gss_buffer_desc major_err = { 0 }; gss_buffer_desc minor_err = { 0 }; int msglen = 0; - char *pmsg = NULL; + MI_Char *pmsg = NULL; if (major_status != 0) @@ -2076,7 +2076,7 @@ static MI_Boolean _WriteAuthRequest(HttpClient_SR_SocketData * handler, const ch total_sent += sent; } - while (total_sent < requestLen); + while ((int)total_sent < requestLen); if (FORCE_TRACING || ((total_sent > 0) && handler->enableTracing)) { @@ -2840,7 +2840,7 @@ Http_CallbackResult HttpClient_IsAuthorized(_In_ struct _HttpClient_SR_SocketDat #define BASIC_AUTH_FAIL_MSG "Basic Authorization failed for user " int msglen = MI_COUNT(BASIC_AUTH_FAIL_MSG)-1; int username_len = strlen(self->username); - char *pmsg = NULL; + MI_Char *pmsg = NULL; if (username_len > USERNAME_LIMIT) { @@ -2858,7 +2858,7 @@ Http_CallbackResult HttpClient_IsAuthorized(_In_ struct _HttpClient_SR_SocketDat client->probableCause->probable_cause_id = WSMAN_CIMERROR_PROBABLE_CAUSE_AUTHENTICATION_FAILURE; client->probableCause->description = (MI_Char *)(client->probableCause+1); - self->errMsg = (char*)(client->probableCause+1); + self->errMsg = (MI_Char*)(client->probableCause+1); pmsg = self->errMsg; memcpy(pmsg, BASIC_AUTH_FAIL_MSG, msglen); pmsg += msglen; diff --git a/Unix/mof/types.c b/Unix/mof/types.c index 8b4b807e..47694097 100644 --- a/Unix/mof/types.c +++ b/Unix/mof/types.c @@ -2704,11 +2704,11 @@ void MOF_PrintInstanceDecl( /* properties */ if (self->properties) - _PrintProperties(self->properties, self->numProperties, level, file); + _PrintProperties((MI_PropertyDecl**)self->properties, (size_t)self->numProperties, level, file); /* qualifiers */ if (self->qualifiers) - _PrintQualifiers(self->qualifiers, self->numQualifiers, level, file); + _PrintQualifiers((MI_Qualifier**)self->qualifiers, (size_t)self->numQualifiers, level, file); /* Footer */ level--; @@ -3523,7 +3523,7 @@ int FinalizeInstance(MI_InstanceDecl* id) /* For each instance property */ for (i = 0; i < id->numProperties; i++) { - MI_PropertyDecl* p = id->properties[i]; + MI_PropertyDecl* p = (MI_PropertyDecl*)id->properties[i]; MI_PropertyDecl* q = NULL; /* Find the class property with the same name */ @@ -3546,7 +3546,7 @@ int FinalizeInstance(MI_InstanceDecl* id) } /* Promote instance property (to the type given by class property) */ - if (_PromoteValue(p->type, q->type, &p->value) != 0) + if (_PromoteValue(p->type, q->type, (void**)&p->value) != 0) { yyerrorf(ID_INVALID_INITIALIZER, "invalid initializer: \"%s\"", p->name); diff --git a/Unix/omi_error/schema.c b/Unix/omi_error/schema.c index edf1e6bb..145b593c 100644 --- a/Unix/omi_error/schema.c +++ b/Unix/omi_error/schema.c @@ -344,9 +344,9 @@ MI_CONST MI_ClassDecl CIM_Error_rtti = MI_FLAG_CLASS|MI_FLAG_INDICATION, /* flags */ 0x00637209, /* code */ MI_T("CIM_Error"), /* name */ - CIM_Error_quals, /* qualifiers */ + (struct _MI_Qualifier**)CIM_Error_quals, /* qualifiers */ MI_COUNT(CIM_Error_quals), /* numQualifiers */ - CIM_Error_props, /* properties */ + (struct _MI_PropertyDecl**)CIM_Error_props, /* properties */ MI_COUNT(CIM_Error_props), /* numProperties */ sizeof(CIM_Error), /* size */ NULL, /* superClass */ @@ -478,13 +478,13 @@ MI_CONST MI_ClassDecl OMI_Error_rtti = MI_FLAG_CLASS|MI_FLAG_INDICATION, /* flags */ 0x006F7209, /* code */ MI_T("OMI_Error"), /* name */ - OMI_Error_quals, /* qualifiers */ + (struct _MI_Qualifier**)OMI_Error_quals, /* qualifiers */ MI_COUNT(OMI_Error_quals), /* numQualifiers */ - OMI_Error_props, /* properties */ + (struct _MI_PropertyDecl**)OMI_Error_props, /* properties */ MI_COUNT(OMI_Error_props), /* numProperties */ sizeof(OMI_Error), /* size */ - MI_T("CIM_Error"), /* superClass */ - &CIM_Error_rtti, /* superClassDecl */ + (MI_CONST MI_Char*)(MI_T("CIM_Error")), /* superClass */ + (MI_ClassDecl*)&CIM_Error_rtti, /* superClassDecl */ NULL, /* methods */ 0, /* numMethods */ &errorSchemaDecl, /* schema */ diff --git a/Unix/providers/identify/schema.c b/Unix/providers/identify/schema.c index 3e724cd7..9ae2f5ca 100644 --- a/Unix/providers/identify/schema.c +++ b/Unix/providers/identify/schema.c @@ -514,9 +514,9 @@ MI_CONST MI_ClassDecl Identify_rtti = MI_FLAG_CLASS, /* flags */ 0x006F790C, /* code */ MI_T("OMI_Identify"), /* name */ - NULL, /* qualifiers */ + (struct _MI_Qualifier**)NULL, /* qualifiers */ 0, /* numQualifiers */ - Identify_props, /* properties */ + (struct _MI_PropertyDecl**)Identify_props, /* properties */ MI_COUNT(Identify_props), /* numProperties */ sizeof(Identify), /* size */ NULL, /* superClass */ diff --git a/Unix/provmgr/indicationSchema.c b/Unix/provmgr/indicationSchema.c index 4a797d87..5c43ab5c 100644 --- a/Unix/provmgr/indicationSchema.c +++ b/Unix/provmgr/indicationSchema.c @@ -222,9 +222,9 @@ MI_CONST MI_ClassDecl CIM_Indication_rtti = MI_FLAG_CLASS|MI_FLAG_INDICATION|MI_FLAG_ABSTRACT, /* flags */ 0x00636E0E, /* code */ MI_T("CIM_Indication"), /* name */ - CIM_Indication_quals, /* qualifiers */ + (struct _MI_Qualifier**)CIM_Indication_quals, /* qualifiers */ MI_COUNT(CIM_Indication_quals), /* numQualifiers */ - CIM_Indication_props, /* properties */ + (struct _MI_PropertyDecl**)CIM_Indication_props, /* properties */ MI_COUNT(CIM_Indication_props), /* numProperties */ sizeof(CIM_Indication), /* size */ NULL, /* superClass */ @@ -342,13 +342,13 @@ MI_CONST MI_ClassDecl CIM_InstIndication_rtti = MI_FLAG_CLASS|MI_FLAG_INDICATION|MI_FLAG_ABSTRACT, /* flags */ 0x00636E12, /* code */ MI_T("CIM_InstIndication"), /* name */ - CIM_InstIndication_quals, /* qualifiers */ + (struct _MI_Qualifier**)CIM_InstIndication_quals, /* qualifiers */ MI_COUNT(CIM_InstIndication_quals), /* numQualifiers */ - CIM_InstIndication_props, /* properties */ + (struct _MI_PropertyDecl**)CIM_InstIndication_props, /* properties */ MI_COUNT(CIM_InstIndication_props), /* numProperties */ sizeof(CIM_InstIndication), /* size */ - MI_T("CIM_Indication"), /* superClass */ - &CIM_Indication_rtti, /* superClassDecl */ + (MI_CONST MI_Char*)MI_T("CIM_Indication"), /* superClass */ + (MI_ClassDecl*)&CIM_Indication_rtti, /* superClassDecl */ NULL, /* methods */ 0, /* numMethods */ &indicationSchemaDecl, /* schema */ @@ -411,13 +411,13 @@ MI_CONST MI_ClassDecl CIM_InstCreation_rtti = MI_FLAG_CLASS|MI_FLAG_INDICATION, /* flags */ 0x00636E10, /* code */ MI_T("CIM_InstCreation"), /* name */ - CIM_InstCreation_quals, /* qualifiers */ + (struct _MI_Qualifier**)CIM_InstCreation_quals, /* qualifiers */ MI_COUNT(CIM_InstCreation_quals), /* numQualifiers */ - CIM_InstCreation_props, /* properties */ + (struct _MI_PropertyDecl**)CIM_InstCreation_props, /* properties */ MI_COUNT(CIM_InstCreation_props), /* numProperties */ sizeof(CIM_InstCreation), /* size */ - MI_T("CIM_InstIndication"), /* superClass */ - &CIM_InstIndication_rtti, /* superClassDecl */ + (MI_CONST MI_Char*)MI_T("CIM_InstIndication"), /* superClass */ + (MI_ClassDecl*)&CIM_InstIndication_rtti, /* superClassDecl */ NULL, /* methods */ 0, /* numMethods */ &indicationSchemaDecl, /* schema */ @@ -480,13 +480,13 @@ MI_CONST MI_ClassDecl CIM_InstDeletion_rtti = MI_FLAG_CLASS|MI_FLAG_INDICATION, /* flags */ 0x00636E10, /* code */ MI_T("CIM_InstDeletion"), /* name */ - CIM_InstDeletion_quals, /* qualifiers */ + (struct _MI_Qualifier**)CIM_InstDeletion_quals, /* qualifiers */ MI_COUNT(CIM_InstDeletion_quals), /* numQualifiers */ - CIM_InstDeletion_props, /* properties */ + (struct _MI_PropertyDecl**)CIM_InstDeletion_props, /* properties */ MI_COUNT(CIM_InstDeletion_props), /* numProperties */ sizeof(CIM_InstDeletion), /* size */ - MI_T("CIM_InstIndication"), /* superClass */ - &CIM_InstIndication_rtti, /* superClassDecl */ + (MI_CONST MI_Char*)MI_T("CIM_InstIndication"), /* superClass */ + (MI_ClassDecl*)&CIM_InstIndication_rtti, /* superClassDecl */ NULL, /* methods */ 0, /* numMethods */ &indicationSchemaDecl, /* schema */ @@ -621,13 +621,13 @@ MI_CONST MI_ClassDecl CIM_InstMethodCall_rtti = MI_FLAG_CLASS|MI_FLAG_INDICATION, /* flags */ 0x00636C12, /* code */ MI_T("CIM_InstMethodCall"), /* name */ - CIM_InstMethodCall_quals, /* qualifiers */ + (struct _MI_Qualifier**)CIM_InstMethodCall_quals, /* qualifiers */ MI_COUNT(CIM_InstMethodCall_quals), /* numQualifiers */ - CIM_InstMethodCall_props, /* properties */ + (struct _MI_PropertyDecl**)CIM_InstMethodCall_props, /* properties */ MI_COUNT(CIM_InstMethodCall_props), /* numProperties */ sizeof(CIM_InstMethodCall), /* size */ - MI_T("CIM_InstIndication"), /* superClass */ - &CIM_InstIndication_rtti, /* superClassDecl */ + (MI_CONST MI_Char*)MI_T("CIM_InstIndication"), /* superClass */ + (MI_ClassDecl*)&CIM_InstIndication_rtti, /* superClassDecl */ NULL, /* methods */ 0, /* numMethods */ &indicationSchemaDecl, /* schema */ @@ -708,13 +708,13 @@ MI_CONST MI_ClassDecl CIM_InstModification_rtti = MI_FLAG_CLASS|MI_FLAG_INDICATION, /* flags */ 0x00636E14, /* code */ MI_T("CIM_InstModification"), /* name */ - CIM_InstModification_quals, /* qualifiers */ + (struct _MI_Qualifier**)CIM_InstModification_quals, /* qualifiers */ MI_COUNT(CIM_InstModification_quals), /* numQualifiers */ - CIM_InstModification_props, /* properties */ + (struct _MI_PropertyDecl**)CIM_InstModification_props, /* properties */ MI_COUNT(CIM_InstModification_props), /* numProperties */ sizeof(CIM_InstModification), /* size */ - MI_T("CIM_InstIndication"), /* superClass */ - &CIM_InstIndication_rtti, /* superClassDecl */ + (MI_CONST MI_Char*)MI_T("CIM_InstIndication"), /* superClass */ + (MI_ClassDecl*)&CIM_InstIndication_rtti, /* superClassDecl */ NULL, /* methods */ 0, /* numMethods */ &indicationSchemaDecl, /* schema */ @@ -777,13 +777,13 @@ MI_CONST MI_ClassDecl CIM_InstRead_rtti = MI_FLAG_CLASS|MI_FLAG_INDICATION, /* flags */ 0x0063640C, /* code */ MI_T("CIM_InstRead"), /* name */ - CIM_InstRead_quals, /* qualifiers */ + (struct _MI_Qualifier**)CIM_InstRead_quals, /* qualifiers */ MI_COUNT(CIM_InstRead_quals), /* numQualifiers */ - CIM_InstRead_props, /* properties */ + (struct _MI_PropertyDecl**)CIM_InstRead_props, /* properties */ MI_COUNT(CIM_InstRead_props), /* numProperties */ sizeof(CIM_InstRead), /* size */ - MI_T("CIM_InstIndication"), /* superClass */ - &CIM_InstIndication_rtti, /* superClassDecl */ + (MI_CONST MI_Char*)MI_T("CIM_InstIndication"), /* superClass */ + (MI_ClassDecl*)&CIM_InstIndication_rtti, /* superClassDecl */ NULL, /* methods */ 0, /* numMethods */ &indicationSchemaDecl, /* schema */ diff --git a/Unix/server/servercommon.c b/Unix/server/servercommon.c index b57e6394..7ad78599 100644 --- a/Unix/server/servercommon.c +++ b/Unix/server/servercommon.c @@ -191,7 +191,7 @@ int _ParseHttpPortSpecification(unsigned short **ports, int *size, const char *s err(ZT("memory allocation failure allocating %d bytes"), bytes); } - (*ports)[(*size) - 1] = x; + (*ports)[(*size) - 1] = (unsigned short)x; } } } diff --git a/Unix/sock/addr.c b/Unix/sock/addr.c index 91f851c5..742fd990 100644 --- a/Unix/sock/addr.c +++ b/Unix/sock/addr.c @@ -73,7 +73,7 @@ MI_Result Addr_Init( memcpy(&self->u.sock_addr, rp->ai_addr, (size_t)rp->ai_addrlen); /* Set the duplicate copies of family, port and socket type */ - self->sock_addr_size = rp->ai_addrlen; + self->sock_addr_size = (MI_Uint16)rp->ai_addrlen; self->port_high_endian = htons(port); self->is_ipv6 = (rp->ai_family == AF_INET6); diff --git a/Unix/wsman/wsman.c b/Unix/wsman/wsman.c index 6ef5108b..c9271402 100644 --- a/Unix/wsman/wsman.c +++ b/Unix/wsman/wsman.c @@ -1044,9 +1044,8 @@ static int _ValidateEnumerateRequest( selfCD, NULL, WSBUF_FAULT_INTERNAL_ERROR, - ZT("mandatory parameters (className, namespace) " - "are missing for enumerate request")); - + ZT("mandatory parameters (className, namespace) ") + ZT("are missing for enumerate request")); return -1; } @@ -1254,7 +1253,7 @@ static MI_Result _GetHTTPHeaderOpts( Tcslcpy(value, selfCD->headers[i].value, MI_COUNT(value)); - v.string = value; + v.string = (MI_Char*)value; r = __MI_Instance_AddElement( options, From d9707fc8468cff1b3b297f5e829bd117b02f2873 Mon Sep 17 00:00:00 2001 From: gakamath Date: Thu, 23 Feb 2023 16:00:18 +0530 Subject: [PATCH 03/17] Adding underflow check for signed integer datatypes --- Unix/wql/output.c | 20 ++++++++++++++++++++ Unix/wsman/wsbuf.c | 12 ++++++++++++ 2 files changed, 32 insertions(+) diff --git a/Unix/wql/output.c b/Unix/wql/output.c index 9261e348..3ec89596 100644 --- a/Unix/wql/output.c +++ b/Unix/wql/output.c @@ -67,6 +67,10 @@ int WQL_Define(const WQL* self, Buf* out, size_t nindent) _Indent(nindent, out); len = Snprintf(buf, sizeof(buf), " %u,\n", (int)self->nproperties); + if(len<0) + { + return -1; + } Buf_App(out, buf, len); } @@ -133,6 +137,10 @@ int WQL_Define(const WQL* self, Buf* out, size_t nindent) Buf_App(out, STRLIT("WQL_TYPE_BOOLEAN, ")); Buf_App(out, STRLIT("WQL_VALUE_BOOLEAN(")); len = Snprintf(buf, sizeof(buf), "%u", sym->value.boolean); + if(len<0) + { + return -1; + } Buf_App(out, buf, len); Buf_App(out, STRLIT(")")); break; @@ -141,6 +149,10 @@ int WQL_Define(const WQL* self, Buf* out, size_t nindent) Buf_App(out, STRLIT("WQL_VALUE_INTEGER(")); len = Snprintf(buf, sizeof(buf), SINT64_FMT, sym->value.integer); + if(len<0) + { + return -1; + } Buf_App(out, buf, len); Buf_App(out, STRLIT(")")); break; @@ -148,6 +160,10 @@ int WQL_Define(const WQL* self, Buf* out, size_t nindent) Buf_App(out, STRLIT("WQL_TYPE_REAL, ")); Buf_App(out, STRLIT("WQL_VALUE_REAL(")); len = Snprintf(buf, sizeof(buf), "%lf", sym->value.real); + if(len<0) + { + return -1; + } Buf_App(out, buf, len); Buf_App(out, STRLIT(")")); break; @@ -225,6 +241,10 @@ int WQL_Define(const WQL* self, Buf* out, size_t nindent) len = Snprintf(buf, sizeof(buf), " %u,\n", (int)self->nsymbols); _Indent(nindent, out); + if(len<0) + { + return -1; + } Buf_App(out, buf, len); } diff --git a/Unix/wsman/wsbuf.c b/Unix/wsman/wsbuf.c index fe4e4c9f..a319368d 100644 --- a/Unix/wsman/wsbuf.c +++ b/Unix/wsman/wsbuf.c @@ -1250,6 +1250,10 @@ static MI_Result _PackFieldSint32( ZChar s[24]; MI_Sint32 size = Stprintf(s, MI_COUNT(s), ZT("%d"), value); + if(size<0) + { + return MI_RESULT_FAILED; + } return _PackFieldStringLit(buf,writer,name,s,size, flags, nsPrefix); } @@ -1264,6 +1268,10 @@ static MI_Result _PackFieldSint64( ZChar s[24]; MI_Sint32 size = Stprintf(s, MI_COUNT(s), SINT64_FMT_T, value); + if(size<0) + { + return MI_RESULT_FAILED; + } return _PackFieldStringLit(buf,writer,name,s,size,flags, nsPrefix); } @@ -1279,6 +1287,10 @@ static MI_Result _PackFieldReal64( /* Use DBL_DIG=15 for precision. Check MSDN DBL_DIG */ MI_Sint32 size = Stprintf(s, MI_COUNT(s), ZT("%.15g"), value); + if(size<0) + { + return MI_RESULT_FAILED; + } return _PackFieldStringLit(buf,writer,name,s,size,flags, nsPrefix); } From 3ba9afda21ea5088fde7fdd20e2fd2534319f307 Mon Sep 17 00:00:00 2001 From: gakamath Date: Thu, 23 Feb 2023 16:04:13 +0530 Subject: [PATCH 04/17] Changing the type of variable to appropriate type from usage --- Unix/base/helpers.c | 4 ++-- Unix/deprecated/logging/logging.h | 2 +- Unix/http/httpclient.c | 11 ++++++----- Unix/http/httpclientauth.c | 4 ++-- Unix/xml/xml.c | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Unix/base/helpers.c b/Unix/base/helpers.c index abdc3512..8ef9169c 100644 --- a/Unix/base/helpers.c +++ b/Unix/base/helpers.c @@ -1061,7 +1061,7 @@ MI_Result MI_CALL Instance_SetElementFromStringA( && ((msgFlags & WSMANFlag) == WSMANFlag)) { size_t sizeIncoming = Tcslen(*data); - int sizeDec = 0; + size_t sizeDec = 0; char * src = (char*) *data; sizeDec = Base64Dec((const void *)src, sizeIncoming, _Base64DecCallback, &v.array); @@ -1257,7 +1257,7 @@ int UsecToDatetime( timeAsUsec /= 60; /* trim down to hours */ x->u.interval.hours = timeAsUsec % 24; timeAsUsec /= 24;/* trim down to days */ - x->u.interval.days = timeAsUsec; + x->u.interval.days = (MI_Uint32)timeAsUsec; return 0; } diff --git a/Unix/deprecated/logging/logging.h b/Unix/deprecated/logging/logging.h index b41b981a..7930a21f 100644 --- a/Unix/deprecated/logging/logging.h +++ b/Unix/deprecated/logging/logging.h @@ -88,7 +88,7 @@ extern unsigned long get_tid(); extern const char* mistrerror(MI_Result res); extern const char* selectorflagstr(MI_Uint32 Flags); extern const char* bitnumberstr(unsigned long Bits); -extern const char* sslstrerror(int SslError); +extern const char* sslstrerror(unsigned long SslError); extern const char* notifyitemtypestr(int NotifyItemType); extern const char* clientstatusstr(int Status); extern const char* messagetagnamestr(int Tag); diff --git a/Unix/http/httpclient.c b/Unix/http/httpclient.c index 5d9dd67e..41cb8b0d 100644 --- a/Unix/http/httpclient.c +++ b/Unix/http/httpclient.c @@ -2024,7 +2024,7 @@ Page* _CreateHttpHeader( pageSize += Strlen(hostHeader) + 2; if (extraHeaders) { - int i; + size_t i; for (i = 0; i < extraHeaders->size; ++i) { pageSize += Strlen(extraHeaders->data[i]) + 2; @@ -2163,7 +2163,7 @@ Page* _CreateHttpHeader( if (extraHeaders) { - int i; + size_t i; for (i = 0; i < extraHeaders->size; ++i) { r = (int)Strlcpy(p, extraHeaders->data[i], pageSize); @@ -3030,7 +3030,8 @@ MI_Result HttpClient_StartRequest( HttpClientRequestHeaders *headers, Page** data) -{ char *content_type = NULL; +{ + char *content_type = NULL; char *auth_header = NULL; HttpClientRequestHeaders extra_headers = { NULL, 0 }; const char** tmp_headers = NULL; @@ -3045,8 +3046,8 @@ MI_Result HttpClient_StartRequest( { tmp_headers = (headers->size != 0) ? (const char **)PAL_Malloc(sizeof(char *) * headers->size) : NULL; - int i = 0; - int j = 0; + size_t i = 0; + size_t j = 0; for (i = 0; i < headers->size; i++ ) { if (Strncasecmp(headers->data[i], CONTENT_TYPE_HDR, CONTENT_TYPE_HDR_LEN) == 0) diff --git a/Unix/http/httpclientauth.c b/Unix/http/httpclientauth.c index 22d72503..fb602134 100644 --- a/Unix/http/httpclientauth.c +++ b/Unix/http/httpclientauth.c @@ -1082,7 +1082,7 @@ MI_Boolean HttpClient_DecryptData(_In_ HttpClient_SR_SocketData * handler, _Out_ return FALSE; } - int i = 0; + MI_Uint32 i = 0; for (i = 0; i < pHeaders->sizeHeaders; i++ ) { if (strncasecmp(pHeaders->headers[i].name, CONTENT_TYPE, CONTENT_TYPE_LEN) == 0) @@ -2782,7 +2782,7 @@ Http_CallbackResult HttpClient_IsAuthorized(_In_ struct _HttpClient_SR_SocketDat HttpClientResponseHeader *pheaders = &self->recvHeaders; char *auth_header = NULL; - int i = 0; + size_t i = 0; // For unit test if (IsAuthCallsIgnored()) diff --git a/Unix/xml/xml.c b/Unix/xml/xml.c index 163c090a..e34026a0 100644 --- a/Unix/xml/xml.c +++ b/Unix/xml/xml.c @@ -1725,7 +1725,7 @@ int XML_ParseCharFault(const XML *self, const XML_Char *data, XML_Char *buffer, { #define PREFIX_SIZE 32 XML_Char prefix[PREFIX_SIZE]; - int i, j, k, l; + size_t i, j, k, l; MI_Boolean prefixFound = MI_FALSE; for (i=0; i Date: Thu, 23 Feb 2023 16:06:23 +0530 Subject: [PATCH 05/17] Changing the tag from SOAP to s as per DMTF DSP specification examples This helps in reducing the size of XML traffic as this tag is used in multiple places --- Unix/wsman/wsbuf.c | 92 +++++++++++++++++++++++----------------------- Unix/wsman/wsman.c | 58 ++++++++++++++--------------- 2 files changed, 75 insertions(+), 75 deletions(-) diff --git a/Unix/wsman/wsbuf.c b/Unix/wsman/wsbuf.c index a319368d..da5d59b2 100644 --- a/Unix/wsman/wsbuf.c +++ b/Unix/wsman/wsbuf.c @@ -111,98 +111,98 @@ static const BUF_FaultItem s_faults[] = { /* WSBUF_FAULT_INTERNAL_ERROR */ { LIT(ZT("http://schemas.dmtf.org/wbem/wsman/1/wsman/fault")), - "SOAP-ENV:Receiver", + "s:Receiver", "wsman:InternalError", ZT("The service cannot comply with the request due to internal processing errors.") }, /* WSBUF_FAULT_NOT_SUPPORTED */ { LIT(ZT("http://schemas.dmtf.org/wbem/wsman/1/wsman/fault")), - "SOAP-ENV:Sender", + "s:Sender", "wsman:UnsupportedFeature", ZT("not supported") }, /* WSBUF_FAULT_NOT_UNDERSTOOD */ { LIT(ZT("http://schemas.xmlsoap.org/ws/2004/08/addressing/fault")), - "SOAP-ENV:MustUnderstand", + "s:MustUnderstand", 0, ZT("Header not understood") }, /* WSBUF_FAULT_DESTINATION_UNREACHABLE */ { LIT(ZT("http://schemas.xmlsoap.org/ws/2004/08/addressing/fault")), - "SOAP-ENV:Sender", + "s:Sender", "wsa:DestinationUnreachable", ZT("No route can be determined to reach the destination role defined by the Addressing To header.") }, /* WSBUF_FAULT_ACCESS_DENIED */ { LIT(ZT("http://schemas.dmtf.org/wbem/wsman/1/wsman/fault")), - "SOAP-ENV:Sender", + "s:Sender", "wsman:AccessDenied", ZT("The sender was not authorized to access the resource.") }, /* WSBUF_FAULT_ENCODING_LIMIT */ { LIT(ZT("http://schemas.dmtf.org/wbem/wsman/1/wsman/fault")), - "SOAP-ENV:Sender", + "s:Sender", "wsman:EncodingLimit", ZT("An internal encoding limit was exceeded in a request or would be violated if the message were processed.") }, /* WSBUF_FAULT_INVALID_EXPIRATION_TIME */ { LIT(ZT("http://schemas.dmtf.org/wbem/wsman/1/wsman/fault")), - "SOAP-ENV:Sender", + "s:Sender", "wsman:InvalidExpirationTime", ZT("The request specified an invalid expiration time that cannot be supported (zero or in the past).") }, /* WSBUF_FAULT_UNSUPPORTED_EXPIRATION_TIME */ { LIT(ZT("http://schemas.dmtf.org/wbem/wsman/1/wsman/fault")), - "SOAP-ENV:Sender", + "s:Sender", "wsman:UnsupportedExpirationTime", ZT("Only xs:duration expiration values are supported.") }, /* WSBUF_FAULT_TIMED_OUT */ { LIT(ZT("http://schemas.dmtf.org/wbem/wsman/1/wsman/fault")), - "SOAP-ENV:Receiver", + "s:Receiver", "wsman:TimedOut", ZT("The operation has timed out.") }, /* WSBUF_FAULT_INVALID_MESSAGE_INFORMATION_HEADER */ { LIT(ZT("http://schemas.xmlsoap.org/ws/2004/08/addressing/fault")), - "SOAP-ENV:Sender", + "s:Sender", "wsa:InvalidMessageInformationHeader", ZT("The request specified an invalid header property.") }, /* WSBUF_FAULT_INVALID_HEARTBEAT */ { LIT(ZT("http://schemas.dmtf.org/wbem/wsman/1/wsman/faultDetail/Heartbeats")), - "SOAP-ENV:Sender", + "s:Sender", "wsman:UnsupportedFeature", ZT("The request specified an invalid heartbeat.") }, /* WSBUF_FAULT_ACTION_NOT_SUPPORTED */ { LIT(ZT("http://schemas.xmlsoap.org/ws/2004/08/addressing/fault")), - "SOAP-ENV:Sender", + "s:Sender", "wsa:ActionNotSupported", ZT("The request specified an unsupported action.") }, /* WSBUF_FAULT_CONNECTION_RETRY_NOT_SUPPORTED */ { LIT(ZT("http://schemas.dmtf.org/wbem/wsman/1/wsman/faultDetail/DeliveryRetries")), - "SOAP-ENV:Sender", + "s:Sender", "wsman:UnsupportedFeature", ZT("Connection retry is not supported.") }, /* WSBUF_FAULT_BOOKMARK_INVALID_FORMAT */ { LIT(ZT("http://schemas.dmtf.org/wbem/wsman/1/wsman/faultDetail/InvalidFormat")), - "SOAP-ENV:Sender", + "s:Sender", "wsman:InvalidBookmark", ZT("Bookmark must be non-empty if specified.") } @@ -2385,8 +2385,8 @@ MI_Result WSBuf_CreateSoapResponseHeader( /* Response header */ if (MI_RESULT_OK != WSBuf_AddLit(buf, LIT( - ZT("") - ZT("") + ZT("") ZT("http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous") - ZT("")))) + ZT("")))) { goto failed; } @@ -2410,7 +2410,7 @@ MI_Result WSBuf_CreateSoapResponseHeader( if (MI_RESULT_OK != WSBuf_AddLit(buf, LIT(ZT("") - ZT("")))) + ZT("")))) goto failed; /* Generate new uniqueue msg id */ @@ -2475,7 +2475,7 @@ Page* WSBuf_CreateFaultResponsePage( if (notUnderstoodTag) { if (MI_RESULT_OK != WSBuf_AddLit(&outBuf, - LIT(ZT("") - ZT("") - ZT("") - ZT("") - ZT("")))) + ZT("") + ZT("") + ZT("") + ZT("") + ZT("")))) goto failed; if (MI_RESULT_OK != WSBuf_AddCharStringNoEncoding(&outBuf, fault->code)) goto failed; - //SOAP-ENV:Sender + //s:Sender if (MI_RESULT_OK != WSBuf_AddLit(&outBuf, - LIT(ZT("")))) + LIT(ZT("")))) goto failed; if (fault->subCode) { if (MI_RESULT_OK != WSBuf_AddLit(&outBuf, - LIT(ZT("") - ZT("")))) + LIT(ZT("") + ZT("")))) goto failed; if (MI_RESULT_OK != WSBuf_AddCharStringNoEncoding( @@ -2521,15 +2521,15 @@ Page* WSBuf_CreateFaultResponsePage( } if (MI_RESULT_OK != WSBuf_AddLit(&outBuf, - LIT(ZT("") - ZT("")))) + LIT(ZT("") + ZT("")))) goto failed; } if (MI_RESULT_OK != WSBuf_AddLit(&outBuf, - LIT(ZT("") - ZT("") - ZT("")))) + LIT(ZT("") + ZT("") + ZT("")))) goto failed; textToSend = fault->defaultText; @@ -2545,8 +2545,8 @@ Page* WSBuf_CreateFaultResponsePage( } if (MI_RESULT_OK != WSBuf_AddLit(&outBuf, - LIT(ZT("") - ZT("")))) + LIT(ZT("") + ZT("")))) { goto failed; } @@ -2558,7 +2558,7 @@ Page* WSBuf_CreateFaultResponsePage( * only have 1 right now so this works! */ if ((MI_RESULT_OK != WSBuf_AddLit(&outBuf, - LIT(ZT("") + LIT(ZT("") ZT("") - ZT("")))) + ZT("")))) { goto failed; } } else if ((message->result != MI_RESULT_OK) || (NULL != message->packedInstancePtr)) { - if ((MI_RESULT_OK != WSBuf_AddLit(&outBuf, LIT(ZT("")ZT("")ZT("cimErrorClassName?message->cimErrorClassName:ZT("OMI_Error")))) || (MI_RESULT_OK != WSBuf_AddLit(&outBuf, LIT(ZT(" wsmb:IsCIM_Error=\"true\" ") @@ -2769,16 +2769,16 @@ Page* WSBuf_CreateFaultResponsePage( if ((MI_RESULT_OK != WSBuf_AddLit(&outBuf, LIT(ZT("cimErrorClassName?message->cimErrorClassName:ZT("OMI_Error")))) || - (MI_RESULT_OK != WSBuf_AddLit(&outBuf, LIT(ZT(">") ZT("")))))) + (MI_RESULT_OK != WSBuf_AddLit(&outBuf, LIT(ZT(">") ZT("")))))) { goto failed; } } if (MI_RESULT_OK != WSBuf_AddLit(&outBuf, - LIT(ZT("") - ZT("") - ZT("")))) + LIT(ZT("") + ZT("") + ZT("")))) { goto failed; } @@ -2808,9 +2808,9 @@ Page* WSBuf_CreateReleaseResponsePage( if (MI_RESULT_OK != WSBuf_AddLit(&outBuf, LIT( - ZT("") - ZT("") - ZT("")))) + ZT("") + ZT("") + ZT("")))) goto failed; return WSBuf_StealPage(&outBuf); diff --git a/Unix/wsman/wsman.c b/Unix/wsman/wsman.c index c9271402..e531c7dd 100644 --- a/Unix/wsman/wsman.c +++ b/Unix/wsman/wsman.c @@ -76,8 +76,8 @@ STRAND_DEBUGNAME2( WsmanEnumerationContext, PullAttached, UnsubscribeAttached ) const MI_Uint64 WSMAN_TIMEOUT_DEFAULT = 60 * 1000 * 1000; // 60 Seconds in microseconds #define TYPICAL_ENUM_RESPONSE_ENVELOPE \ - "\n" \ - "\n" \ + "\n" \ "\n" \ "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous\n" \ "\n" \ - "\n" \ + "\n" \ "http://schemas.xmlsoap.org/ws/2004/09/enumeration/EnumerateResponse\n" \ "\n" \ - "\n" \ + "\n" \ "uuid:00000000-0000-0000-0000-000000000000\n" \ "\n" \ "\n" \ "uuid:00000000-0000-0000-0000-000000000000\n" \ "\n" \ - "\n" \ - "\n" \ + "\n" \ + "\n" \ "\n" \ "\n" \ "000000000000\n" \ @@ -117,8 +117,8 @@ const MI_Uint64 WSMAN_TIMEOUT_DEFAULT = 60 * 1000 * 1000; // 60 Seconds in micro "\n" \ "\n" \ "\n" \ - "\n" \ - "\n" + "\n" \ + "\n" /* aproximate repsonse header size */ #define APPROX_ENUM_RESP_ENVELOPE_SIZE \ @@ -2694,8 +2694,8 @@ static void _SendEnumPullResponse( } if (MI_RESULT_OK != WSBuf_AddLit(&outBufHeader, - LIT(ZT("") - ZT("")))) + LIT(ZT("") + ZT("")))) GOTO_FAILED; if (selfCD->wsheader.rqtAction == WSMANTAG_ACTION_ENUMERATE) @@ -2803,8 +2803,8 @@ static void _SendEnumPullResponse( GOTO_FAILED; } if (MI_RESULT_OK != WSBuf_AddLit(&outBufTrailer, - LIT(ZT("") - ZT("")))) + LIT(ZT("") + ZT("")))) GOTO_FAILED; /* all together */ @@ -2981,8 +2981,8 @@ static void _SendInvokeResponse( GOTO_FAILED; if (MI_RESULT_OK != WSBuf_AddLit(&outBuf, - LIT(ZT("") - ZT("")))) + LIT(ZT("") + ZT("")))) { GOTO_FAILED; } @@ -2997,8 +2997,8 @@ static void _SendInvokeResponse( if (MI_RESULT_OK != WSBuf_AddLit( &outBuf, - LIT(ZT("") - ZT("")))) + LIT(ZT("") + ZT("")))) { GOTO_FAILED; } @@ -3053,8 +3053,8 @@ static void _SendSingleResponseHelper( GOTO_FAILED; if (MI_RESULT_OK != WSBuf_AddLit(&outBuf, - LIT(ZT("") - ZT("") + LIT(ZT("") + ZT("") ))) GOTO_FAILED; @@ -3072,8 +3072,8 @@ static void _SendSingleResponseHelper( /* trailer */ if (MI_RESULT_OK != WSBuf_AddLit(&outBuf, LIT( - ZT("") - ZT("")))) + ZT("") + ZT("")))) GOTO_FAILED; /* all together */ @@ -3132,9 +3132,9 @@ static void _SendEmptyBodyResponse(WSMAN_ConnectionData* selfCD, GOTO_FAILED; if (MI_RESULT_OK != WSBuf_AddLit(&outBuf, - LIT(ZT("") - ZT("") - ZT("") + LIT(ZT("") + ZT("") + ZT("") ))) GOTO_FAILED; @@ -4769,16 +4769,16 @@ static void _SendHeartbeatResponse( GOTO_FAILED; if (MI_RESULT_OK != WSBuf_AddLit(&outBuf, - LIT(ZT("") - ZT("") + LIT(ZT("") + ZT("") ))) GOTO_FAILED; / * trailer * / if (MI_RESULT_OK != WSBuf_AddLit(&outBuf, LIT( - ZT("") - ZT("")))) + ZT("") + ZT("")))) GOTO_FAILED; / * all together * / @@ -4829,7 +4829,7 @@ static void _SendUnsubscribeResponse( GOTO_FAILED; if (MI_RESULT_OK != WSBuf_AddLit(&outBuf, - LIT(ZT("\n\n") + LIT(ZT("\n\n") ))) GOTO_FAILED; From c1c7e6efa6dfe8fb7235e0c6e6c102d39a4b2221 Mon Sep 17 00:00:00 2001 From: gakamath Date: Thu, 23 Feb 2023 16:12:39 +0530 Subject: [PATCH 06/17] Setting default value of array to 0. Initializing some variables --- Unix/base/log.c | 2 +- Unix/base/preexec.c | 14 +++++++------- Unix/base/user.c | 4 ++-- Unix/http/http.c | 6 +++--- Unix/http/httpclient.c | 2 +- Unix/protocol/protocol.c | 8 ++++---- Unix/server/server.c | 2 +- Unix/server/servercommon.c | 2 +- Unix/wsman/wsman.c | 4 ++-- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Unix/base/log.c b/Unix/base/log.c index 32f42549..a8582875 100644 --- a/Unix/base/log.c +++ b/Unix/base/log.c @@ -188,7 +188,7 @@ static void _PutHeader( unsigned int line, Log_Level level) { - char buf[TIMESTAMP_SIZE]; + char buf[TIMESTAMP_SIZE] = { 0 }; GetTimeStamp(buf); Ftprintf(os, ZT("%s "), scs(buf)); diff --git a/Unix/base/preexec.c b/Unix/base/preexec.c index 14dc46dc..fc8fc0c4 100644 --- a/Unix/base/preexec.c +++ b/Unix/base/preexec.c @@ -167,10 +167,10 @@ int PreExec_CheckExec( uid_t uid, uid_t gid) { - char key[PAL_MAX_PATH_SIZE]; - char uidBuf[11]; + char key[PAL_MAX_PATH_SIZE] = { 0 }; + char uidBuf[11] = { 0 }; const char* uidStr; - char gidBuf[11]; + char gidBuf[11] = { 0 }; const char* gidStr; /* If no pre-exec program, nothing to do */ @@ -252,9 +252,9 @@ int PreExec_ExecuteOnServer( /* Child Process here... */ const char *uidStr; const char *gidStr; - char uidBuf[11]; - char gidBuf[11]; - char path[PAL_MAX_PATH_SIZE]; + char uidBuf[11] = { 0 }; + char gidBuf[11] = { 0 }; + char path[PAL_MAX_PATH_SIZE] = { 0 }; /* Form the UID string */ { @@ -327,7 +327,7 @@ int PreExec_ExecuteOnServer( else { pid_t r; - int status; + int status = 0; /* Parent Process */ r = waitpid(pid, &status, 0); diff --git a/Unix/base/user.c b/Unix/base/user.c index 131edc27..8b8ad595 100644 --- a/Unix/base/user.c +++ b/Unix/base/user.c @@ -379,7 +379,7 @@ int LookupUser(const char* user, uid_t* uid, gid_t* gid) int GetUserGidByUid(uid_t uid, gid_t* gid) { /* user name */ - char name[USERNAME_SIZE]; + char name[USERNAME_SIZE] = {0}; if (0 != GetUserName((LPSTR)uid, (LPDWORD)name)) return -1; @@ -834,7 +834,7 @@ int IsUserAuthorized(const char *user, gid_t gid) #else typedef gid_t group_type; #endif - group_type groups[MAX_GROUPS]; + group_type groups[MAX_GROUPS] = { 0 }; int ngroups = MAX_GROUPS; int i; diff --git a/Unix/http/http.c b/Unix/http/http.c index 70bccd60..24c288e9 100644 --- a/Unix/http/http.c +++ b/Unix/http/http.c @@ -821,7 +821,7 @@ _BuildHeader( Http_SR_SocketData* handler, int contentLen, const char *perrcode_desc = _HttpErrorCodeDescription(handler->httpErrorCode, &errcode_desc_len); int content_len_strlen = 0; - char content_len_buff[16] ; + char content_len_buff[16] = { 0 }; char *pcontent_len = int64_to_a(content_len_buff, sizeof(content_len_buff), contentLen, &content_len_strlen); int needed_size = HTTP_PROTOCOL_HEADER_LEN + errorcode_strlen + 1 + errcode_desc_len + 2 + // HTTP/1.1 0 200 Success\r\n @@ -1685,7 +1685,7 @@ static MI_Result _CreateSSLContext(Http* self, const char* sslCipherSuite, SSL_O ** certificate. */ { - char errorBuf[256]; + char errorBuf[256] = { 0 }; /* load the specified server certificates */ trace_SSL_LoadingServerCert(scs(OMI_GetPath(ID_PEMFILE))); @@ -1705,7 +1705,7 @@ static MI_Result _CreateSSLContext(Http* self, const char* sslCipherSuite, SSL_O ** If specified, validate and load the key. */ { - char errorBuf[256]; + char errorBuf[256] = { 0 }; /* load the specified server certificates */ trace_SSL_LoadingCertPrivateKey(scs(OMI_GetPath(ID_KEYFILE))); diff --git a/Unix/http/httpclient.c b/Unix/http/httpclient.c index 41cb8b0d..624e3ffc 100644 --- a/Unix/http/httpclient.c +++ b/Unix/http/httpclient.c @@ -560,7 +560,7 @@ static void _WriteTraceSessionTimestamp(_In_ PathID pathId, _In_opt_z_ const cha // [Session: NNNNN Date: YYYY/MM/DD HH:MM:SS.1234567Z] #define SESSION_DATETIME_SIZE 70 const char FMT[] = "[Session: %s Date: %04d-%02d-%02d %02d:%02d:%02d.%07dZ]"; - char buf[SESSION_DATETIME_SIZE]; + char buf[SESSION_DATETIME_SIZE] = { 0 }; struct timeval tv; struct tm tm; diff --git a/Unix/protocol/protocol.c b/Unix/protocol/protocol.c index 4e8545ff..b5cb5869 100644 --- a/Unix/protocol/protocol.c +++ b/Unix/protocol/protocol.c @@ -1175,7 +1175,7 @@ static MI_Boolean _ProcessCreateAgentMsg( { /* create/open log file for agent */ { - char path[PAL_MAX_PATH_SIZE]; + char path[PAL_MAX_PATH_SIZE] = { 0 }; if (0 != FormatLogFileName(agentMsg->uid, agentMsg->gid, agentMsg->libraryName, path)) { @@ -1199,11 +1199,11 @@ static MI_Boolean _ProcessCreateAgentMsg( char param_sock[32]; char param_logfd[32]; const char *agentProgram = OMI_GetPath(ID_AGENTPROGRAM); - char realAgentProgram[PATH_MAX]; + char realAgentProgram[PATH_MAX] = { 0 }; const char *destDir = OMI_GetPath(ID_DESTDIR); - char realDestDir[PATH_MAX]; + char realDestDir[PATH_MAX] = { 0 }; const char *provDir = OMI_GetPath(ID_PROVIDERDIR); - char realProvDir[PATH_MAX]; + char realProvDir[PATH_MAX] = { 0 }; char *ret; ret = realpath(agentProgram, realAgentProgram); diff --git a/Unix/server/server.c b/Unix/server/server.c index 535b3108..c58051fe 100644 --- a/Unix/server/server.c +++ b/Unix/server/server.c @@ -479,7 +479,7 @@ int servermain(int argc, const char* argv[], const char *envp[]) int engine_argc = 0; char **engine_argv = NULL; char **engine_envp = NULL; - char socketFile[PAL_MAX_PATH_SIZE]; + char socketFile[PAL_MAX_PATH_SIZE] = { 0 }; const char* arg0 = argv[0]; MI_Result result; int r; diff --git a/Unix/server/servercommon.c b/Unix/server/servercommon.c index 7ad78599..d91ab4d5 100644 --- a/Unix/server/servercommon.c +++ b/Unix/server/servercommon.c @@ -143,7 +143,7 @@ int _ParseHttpPortSpecification(unsigned short **ports, int *size, const char *s *size = 0; // Skip leading spaces - char *saveptr; + char *saveptr = NULL; char *ptr = (char *) spec; while (*ptr == ' ') { diff --git a/Unix/wsman/wsman.c b/Unix/wsman/wsman.c index e531c7dd..024b2b9d 100644 --- a/Unix/wsman/wsman.c +++ b/Unix/wsman/wsman.c @@ -1243,8 +1243,8 @@ static MI_Result _GetHTTPHeaderOpts( for (i = 0; i < selfCD->headersSize; i++) { MI_Value v; - ZChar name[128]; - ZChar value[128]; + ZChar name[128] = { 0 }; + ZChar value[128] = { 0 }; Tcslcpy(name, MI_T("HTTP_"), MI_COUNT(name)); TcsStrlcat(name, selfCD->headers[i].name, MI_COUNT(name)); From 913b119973921d092d7d635547239824de1ac580 Mon Sep 17 00:00:00 2001 From: gakamath Date: Mon, 27 Feb 2023 15:24:47 +0530 Subject: [PATCH 07/17] Adding return case in case of failures --- Unix/server/servercommon.c | 2 ++ Unix/wsman/wsbuf.c | 9 ++++++--- Unix/xmlserializer/xmlserializer.c | 28 ++++++++++++++++++++++++++-- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Unix/server/servercommon.c b/Unix/server/servercommon.c index d91ab4d5..a3c51f17 100644 --- a/Unix/server/servercommon.c +++ b/Unix/server/servercommon.c @@ -1020,6 +1020,7 @@ static void _ProcessNoopRequest(_Inout_ InteractionOpenParams* params) trace_OutOfMemory(); Strand_FailOpen(params); err(ZT("out of memory")); + return; } /* Send NoOp response back */ @@ -1030,6 +1031,7 @@ static void _ProcessNoopRequest(_Inout_ InteractionOpenParams* params) trace_OutOfMemory(); Strand_FailOpen(params); err(ZT("out of memory")); + return; } #if !defined(CONFIG_FAVORSIZE) diff --git a/Unix/wsman/wsbuf.c b/Unix/wsman/wsbuf.c index da5d59b2..733400af 100644 --- a/Unix/wsman/wsbuf.c +++ b/Unix/wsman/wsbuf.c @@ -778,6 +778,8 @@ MI_Result WSBuf_AddString( ZChar* pos = start; ZChar* end = (ZChar*)(((char*)(buf->page +1))+ buf->page->u.s.size); /* Add reamingin characters (next character is special)*/ + if (str == NULL) + return MI_RESULT_OK; while (*str) { const ZChar* item; @@ -1576,9 +1578,10 @@ static MI_Result _PackEPR( /* namespace (if present)*/ if (self->nameSpace) { - WSBuf_AddLit(buf, LIT(ZT(""))); - WSBuf_AddStringNoEncoding(buf, self->nameSpace); - WSBuf_AddLit(buf, LIT(ZT(""))); + if(MI_RESULT_OK != WSBuf_AddLit(buf, LIT(ZT(""))) || + MI_RESULT_OK != WSBuf_AddStringNoEncoding(buf, self->nameSpace) || + MI_RESULT_OK != WSBuf_AddLit(buf, LIT(ZT("")))) + return MI_RESULT_FAILED; } /* Put properties */ diff --git a/Unix/xmlserializer/xmlserializer.c b/Unix/xmlserializer/xmlserializer.c index b92754d0..8a64b1dc 100644 --- a/Unix/xmlserializer/xmlserializer.c +++ b/Unix/xmlserializer/xmlserializer.c @@ -126,6 +126,10 @@ static void WriteBuffer_Instance( *result = MI_RESULT_OK; *result = MI_Instance_GetClassExt(instance, &classOfInstance); + if(classOfInstance.ft == NULL) + { + return; + } *result = GetClassExtendedFt(&classOfInstance)->GetClassName(&classOfInstance, &classNameOfInstance); @@ -137,6 +141,10 @@ static void WriteBuffer_Instance( { WriteBuffer_String(clientBuffer, clientBufferLength, clientBufferNeeded, classNameOfInstance, escapingDepth, result); } + else + { + return; + } WriteBuffer_StringLiteral(clientBuffer, clientBufferLength, clientBufferNeeded, PAL_T("\""), escapingDepth, result); WriteBuffer_StringLiteral(clientBuffer, clientBufferLength, clientBufferNeeded, PAL_T(">"), escapingDepth, result); @@ -271,6 +279,10 @@ static void WriteBuffer_InstanceEmbeddedClass( serverName = embeddedInstance[embeddedInstanceLoop]->serverName; } MI_Instance_GetClassExt(embeddedInstance[embeddedInstanceLoop], &classOfInstance); + if(classOfInstance.ft == NULL) + { + return; + } WriteBuffer_RecurseInstanceClass(clientBuffer, clientBufferLength, clientBufferNeeded, serializeFlags, &classOfInstance, namespaceName, serverName, writtenClasses, writtenClassCount, result); //Recurse in case it has any embedded classes @@ -304,6 +316,10 @@ static void WriteBuffer_SerializeClass( { WriteBuffer_CimName(clientBuffer, clientBufferLength, clientBufferNeeded, miClassName, SERIALIZE_NO_ESCAPE, result); } + else + { + return; + } /* %SuperClass; */ GetClassExtendedFt(miClass)->GetParentClassName(miClass, &miParentClassName); @@ -566,7 +582,8 @@ static void WriteBuffer_MiPropertyDecls( GetClassExtendedFt(miClass)->GetElementAtExt(miClass, propertyCount, &propertyName, &propertyValue, &propertyValueExistsInDecl, &propertyType, &propertySubscript, &propertyOffset , &propertyReferenceClass, &propertyOriginClass, &propertyPropagatorClass, &propertyQualifierSet, &propertyFlags); - MI_Instance_GetElementAt((MI_Instance*)instanceStart, propertyCount, &propertyName, &propertyValue, &propertyType, &propertyFlags); + if(MI_RESULT_OK != MI_Instance_GetElementAt((MI_Instance*)instanceStart, propertyCount, &propertyName, &propertyValue, &propertyType, &propertyFlags)) + return; /* If not serializing deep and we are not the propagator of the property then we need to skip this one */ //MI_SERIALIZER_FLAGS_CLASS_DEEP @@ -1597,7 +1614,10 @@ static void WriteBuffer_INSTANCENAME( MI_Uint32 propertyFlags; *result = MI_Instance_GetClassExt(refValue, &classOfRefValue); - + if(classOfRefValue.ft == NULL) + { + return; + } *result = GetClassExtendedFt(&classOfRefValue)->GetClassName(&classOfRefValue, &classNameOfRefValue); WriteBuffer_StringLiteral(clientBuffer, clientBufferLength, clientBufferNeeded, PAL_T("nameSpace, _instanceObject->serverName, writtenClasses, &writtenClassCount, &result); //Loop through embedded object classes From 73e690c8d0286d225b661ea1c904b2d479fae4a1 Mon Sep 17 00:00:00 2001 From: gakamath Date: Mon, 27 Feb 2023 15:26:23 +0530 Subject: [PATCH 08/17] Fixing improper malloc and free --- Unix/base/class.c | 4 ++-- Unix/base/instance.c | 2 +- Unix/codec/mof/strset.c | 2 +- Unix/engine/engine.c | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Unix/base/class.c b/Unix/base/class.c index 1bc61c1a..d06cd4c9 100644 --- a/Unix/base/class.c +++ b/Unix/base/class.c @@ -1517,7 +1517,7 @@ void* Class_Clone_Value( MI_Char *string = NULL; MI_Char **pointerToString = NULL; - pointerToString = (MI_Char**)Batch_Get(batch, sizeof(MI_Char**)); + pointerToString = (MI_Char**)Batch_Get(batch, sizeof(MI_Char*)); if (pointerToString == NULL) { return NULL; /* Returning NULL causes whole batch to destruct */ @@ -1538,7 +1538,7 @@ void* Class_Clone_Value( MI_Instance *instance = NULL; MI_Instance **pointerToInstance= NULL; - pointerToInstance = (MI_Instance**)Batch_Get(batch, sizeof(MI_Instance**)); + pointerToInstance = (MI_Instance**)Batch_Get(batch, sizeof(MI_Instance*)); if (pointerToInstance == NULL) { return NULL; /* Returning NULL causes whole batch to destruct */ diff --git a/Unix/base/instance.c b/Unix/base/instance.c index 9786a86e..40ba2dd4 100644 --- a/Unix/base/instance.c +++ b/Unix/base/instance.c @@ -1252,7 +1252,7 @@ MI_Result MI_CALL Instance_NewDynamic( MI_PropertyDecl** data; data = (MI_PropertyDecl**)BAlloc(batch, - _CAPACITY * sizeof(MI_PropertyDecl), CALLSITE); + _CAPACITY * sizeof(MI_PropertyDecl*), CALLSITE); if (!data) { diff --git a/Unix/codec/mof/strset.c b/Unix/codec/mof/strset.c index 33f7caef..fabe91b5 100644 --- a/Unix/codec/mof/strset.c +++ b/Unix/codec/mof/strset.c @@ -151,7 +151,7 @@ int StrSet_Add( free(bucket); return 1; } - + free(bucket); return 0; } diff --git a/Unix/engine/engine.c b/Unix/engine/engine.c index b07ea39f..ad220e34 100644 --- a/Unix/engine/engine.c +++ b/Unix/engine/engine.c @@ -98,6 +98,7 @@ int enginemain(int argc, const char* argv[]) // binary connection with client const char *path = OMI_GetPath(ID_SOCKETFILE); result = BinaryProtocolListenFile(path, &s_data.mux[0], &s_data.protocol0); + free((void *)path); if (result != MI_RESULT_OK) { err(ZT("Failed to initialize binary protocol for socket file")); From 392749bf5841fc5feb985717d3928cc0f7d754a9 Mon Sep 17 00:00:00 2001 From: gakamath Date: Mon, 27 Feb 2023 15:28:44 +0530 Subject: [PATCH 09/17] Correcting comments and spelling --- Unix/http/http.c | 4 ++-- Unix/provreg/provreg.c | 4 ++-- Unix/provreg/provreg.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Unix/http/http.c b/Unix/http/http.c index 24c288e9..ea524adf 100644 --- a/Unix/http/http.c +++ b/Unix/http/http.c @@ -222,7 +222,7 @@ static MI_Boolean _getHeaderField( } break; } - case (_HashCode('u','t',10)): + case (_HashCode('u', 't', 10)): /*User-Agent*/ { /* Remember the User-Agent for later use */ if (Strcasecmp(name, "User-Agent") == 0) @@ -231,7 +231,7 @@ static MI_Boolean _getHeaderField( } break; } - case (_HashCode('p', 't', 4)): + case (_HashCode('p', 't', 4)): /*POST*/ { /* Remember the User-Agent for later use */ if (Strcasecmp(name, "POST") == 0) diff --git a/Unix/provreg/provreg.c b/Unix/provreg/provreg.c index eccb052c..5e415fe1 100644 --- a/Unix/provreg/provreg.c +++ b/Unix/provreg/provreg.c @@ -694,7 +694,7 @@ static int _AddEntryForExtraClass( return 0; } -/* Initialize ProvReg strucutre from given directory */ +/* Initialize ProvReg structure from given directory */ _Use_decl_annotations_ MI_Result ProvReg_Init(ProvReg* self, const char* directory) { @@ -875,7 +875,7 @@ MI_Result ProvReg_Init(ProvReg* self, const char* directory) return r; } -/* Initialize ProvReg strucutre from omiregister directory */ +/* Initialize ProvReg structure from omiregister directory */ _Use_decl_annotations_ MI_Result ProvReg_Init2(ProvReg* self) { diff --git a/Unix/provreg/provreg.h b/Unix/provreg/provreg.h index bae16be5..eb1b0590 100644 --- a/Unix/provreg/provreg.h +++ b/Unix/provreg/provreg.h @@ -119,12 +119,12 @@ typedef struct _ProvReg } ProvReg; -/* Initialize ProvReg strucutre from given directory */ +/* Initialize ProvReg structure from given directory */ MI_Result ProvReg_Init( _Inout_ ProvReg* self, _In_z_ const char* directory); -/* Initialize ProvReg strucutre from omiregister directory */ +/* Initialize ProvReg structure from omiregister directory */ MI_Result ProvReg_Init2( _Inout_ ProvReg* self); From ef9fbc87dea8606e2c2a38ed48976b29d24fd725 Mon Sep 17 00:00:00 2001 From: gakamath Date: Mon, 27 Feb 2023 15:29:57 +0530 Subject: [PATCH 10/17] Calling MI_T macro to decide the type of cast for const char * --- Unix/agent/agent.c | 8 ++++---- Unix/omireg/omireg.cpp | 10 +++++----- Unix/server/servercommon.c | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Unix/agent/agent.c b/Unix/agent/agent.c index 1a9c5e4d..10f1a0db 100644 --- a/Unix/agent/agent.c +++ b/Unix/agent/agent.c @@ -100,7 +100,7 @@ void ResetLog() conf = Conf_Open(path); if (!conf) { - trace_CriticalError("Failed to open configuration file"); + trace_CriticalError(MI_T("Failed to open configuration file")); return; } @@ -113,7 +113,7 @@ void ResetLog() if (r == -1) { - trace_CriticalError("Incorrect entry in configuration file"); + trace_CriticalError(MI_T("Incorrect entry in configuration file")); break; } @@ -124,7 +124,7 @@ void ResetLog() { if (Log_SetLevelFromString(value) != 0) { - trace_CriticalError("Incorrect loglevel set in configuration file"); + trace_CriticalError(MI_T("Incorrect loglevel set in configuration file")); } break; } @@ -312,7 +312,7 @@ static void GetCommandLineOptions(int* argc, const char* argv[]) else if (strcmp(state.opt, "--version") == 0) { Tprintf(ZT("%s: %s\n"), scs(arg0), - scs(CONFIG_PRODUCT "-" CONFIG_VERSION " - " CONFIG_DATE)); + scs((const char *)(CONFIG_PRODUCT MI_T("-") CONFIG_VERSION MI_T(" - ") CONFIG_DATE))); exit(0); } else if (strcmp(state.opt, "--providerdir") == 0) diff --git a/Unix/omireg/omireg.cpp b/Unix/omireg/omireg.cpp index 6ac37ef8..230db45b 100644 --- a/Unix/omireg/omireg.cpp +++ b/Unix/omireg/omireg.cpp @@ -763,12 +763,12 @@ static void _GetConfigFileOptions( /* Form the configuration file path */ if (FindConfigFile(path) != 0) - err("failed to find configuration file"); + err(MI_T("failed to find configuration file")); /* Open the configuration file */ conf = Conf_Open(path); if (!conf) - err("failed to open configuration file: %s", path); + err(MI_T("failed to open configuration file: %s"), path); /* For each key=value pair in configuration file */ for (;;) @@ -778,7 +778,7 @@ static void _GetConfigFileOptions( int r = Conf_Read(conf, &key, &value); if (r == -1) - err("%s: %s\n", path, Conf_Error(conf)); + err(MI_T("%s: %s\n"), path, Conf_Error(conf)); if (r == 1) break; @@ -801,13 +801,13 @@ static void _GetConfigFileOptions( } else { - err("%s(%u): duplicate key: %s", + err(MI_T("%s(%u): duplicate key: %s"), path, Conf_Line(conf), opt.c_str ()); } } } else - err("%s(%u): unknown key: %s", path, Conf_Line(conf), key); + err(MI_T("%s(%u): unknown key: %s"), path, Conf_Line(conf), key); } /* Close configuration file */ diff --git a/Unix/server/servercommon.c b/Unix/server/servercommon.c index a3c51f17..6fdf8f03 100644 --- a/Unix/server/servercommon.c +++ b/Unix/server/servercommon.c @@ -446,7 +446,7 @@ void ResetLog() conf = Conf_Open(path); if (!conf) { - trace_CriticalError("Failed to open configuration file"); + trace_CriticalError(MI_T("Failed to open configuration file")); return; } @@ -459,7 +459,7 @@ void ResetLog() if (r == -1) { - trace_CriticalError("Incorrect entry in configuration file"); + trace_CriticalError(MI_T("Incorrect entry in configuration file")); break; } @@ -470,7 +470,7 @@ void ResetLog() { if (Log_SetLevelFromString(value) != 0) { - trace_CriticalError("Incorrect loglevel set in configuration file"); + trace_CriticalError(MI_T("Incorrect loglevel set in configuration file")); } break; } From c450a4bcef817f7ba7cccc80dde5f4e3bdd847c9 Mon Sep 17 00:00:00 2001 From: gakamath Date: Mon, 27 Feb 2023 15:33:53 +0530 Subject: [PATCH 11/17] Adding check for config file as it crashes when config file is not provided --- Unix/base/user.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Unix/base/user.c b/Unix/base/user.c index 8b8ad595..28f82ac9 100644 --- a/Unix/base/user.c +++ b/Unix/base/user.c @@ -707,6 +707,7 @@ MI_Boolean ValidateGssCredentials(const char *credFilePath, const char *krb5KeyT *p = '\0'; } + if (credFilePath) { struct stat buf = {0}; int rtn = stat(credFilePath, &buf); @@ -862,6 +863,9 @@ int IsUserAuthorized(const char *user, gid_t gid) return 0; #else // non-supported platforms + MI_UNUSED(groups); + MI_UNUSED(ngroups); + MI_UNUSED(i); return 1; #endif } From 7dd983bcf072463fc212657d7c9f63a26a926a04 Mon Sep 17 00:00:00 2001 From: gakamath Date: Mon, 27 Feb 2023 15:35:01 +0530 Subject: [PATCH 12/17] Adding Disable_Shell macro above the call to check for "isShellOperation" as this parameter is defined inside this macro in header file --- Unix/wsman/wsman.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Unix/wsman/wsman.c b/Unix/wsman/wsman.c index 024b2b9d..424f783b 100644 --- a/Unix/wsman/wsman.c +++ b/Unix/wsman/wsman.c @@ -2303,11 +2303,11 @@ static void _ParseValidateProcessCreateRequest( /* Set the user agent */ msg->base.userAgent = selfCD->userAgent; +#ifndef DISABLE_SHELL /* Parse create request/body */ if (WS_ParseCreateBody(xml, msg->base.base.batch, &msg->instance, &selfCD->wsheader.isShellOperation) != 0) GOTO_FAILED; -#ifndef DISABLE_SHELL if (selfCD->wsheader.isCompressed) { MI_Value value; From 5f7e5133f0ed7dcae45aa68717b2abc5bae20a77 Mon Sep 17 00:00:00 2001 From: gakamath Date: Mon, 27 Feb 2023 15:47:34 +0530 Subject: [PATCH 13/17] Adding DISABLE_SHELL macro around related code in wsmanclient.c --- Unix/wsman/wsmanclient.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Unix/wsman/wsmanclient.c b/Unix/wsman/wsmanclient.c index 133e89a7..7364ee4e 100644 --- a/Unix/wsman/wsmanclient.c +++ b/Unix/wsman/wsmanclient.c @@ -800,6 +800,7 @@ void _WsmanClient_Post( _In_ Strand* self_, _In_ Message* msg) self->wsmanSoapHeaders.action = value.string; } +#ifndef DISABLE_SHELL if ((MI_Instance_GetElement(requestMessage->options, MI_T("__MI_OPERATIONOPTIONS_SESSIONID"), &value, @@ -811,6 +812,7 @@ void _WsmanClient_Post( _In_ Strand* self_, _In_ Message* msg) { self->wsmanSoapHeaders.sessionId = value.string; } +#endif if ((MI_Instance_GetElement(requestMessage->options, MI_T("__MI_OPERATIONOPTIONS_ISSHELL"), &value, @@ -841,6 +843,7 @@ void _WsmanClient_Post( _In_ Strand* self_, _In_ Message* msg) break; } +#ifndef DISABLE_SHELL case CreateInstanceReqTag: { CreateInstanceReq *createMessage = (CreateInstanceReq*) msg; @@ -855,7 +858,7 @@ void _WsmanClient_Post( _In_ Strand* self_, _In_ Message* msg) miresult = CreateMessageRequest(&self->wsbuf, &self->wsmanSoapHeaders, createMessage); break; } - +#endif case ModifyInstanceReqTag: { ModifyInstanceReq *putMessage = (ModifyInstanceReq*) msg; From 84cbf7be5e639113a590a0171ac616c94cd68e7d Mon Sep 17 00:00:00 2001 From: gakamath Date: Mon, 27 Feb 2023 15:48:10 +0530 Subject: [PATCH 14/17] Adding void explicitly in the definition of _GssUnloadLibrary to fix compiler warning --- Unix/http/httpclientauth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Unix/http/httpclientauth.c b/Unix/http/httpclientauth.c index fb602134..afb0d098 100644 --- a/Unix/http/httpclientauth.c +++ b/Unix/http/httpclientauth.c @@ -560,7 +560,7 @@ _Success_(return == 0) int _ValidateClientCredentials(HttpClient_SR_SocketData * static void -_GssUnloadLibrary() +_GssUnloadLibrary(void) { dlclose(_g_gssClientState.libHandle); From c8d8070258912bc5f39b77c99b0936e288952ed1 Mon Sep 17 00:00:00 2001 From: gakamath Date: Mon, 27 Feb 2023 15:49:40 +0530 Subject: [PATCH 15/17] renaming parameters as namespace_ and class_ as they are C++ keywords --- Unix/base/oi_traces.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Unix/base/oi_traces.h b/Unix/base/oi_traces.h index 6fee402d..cc89c266 100644 --- a/Unix/base/oi_traces.h +++ b/Unix/base/oi_traces.h @@ -1013,7 +1013,7 @@ void trace_SigTERM_received_OBSOLETE(const char* user); OI_EVENT("Starting %s: version: (%s), platform: (%s)") void trace_Product_Version(const char* product, const char* version, const char* platform); OI_EVENT("New request received: command=(%T), namespace=(%T), class=(%T)") -void trace_New_Request(const TChar* cmd, const TChar* namespace, const TChar* class); +void trace_New_Request(const TChar* cmd, const TChar* namespace_, const TChar* class_); OI_EVENT("WARNING: one or more blocks still allocated!") void trace_DumpAllocList_Warning(); OI_EVENT("BLOCK: %s(%u): ptr=%p: magic=%08X id=%u size=%u") From 92b2d093eb90d2bd302912d1c6246564b0c83fa9 Mon Sep 17 00:00:00 2001 From: gakamath Date: Mon, 27 Feb 2023 15:50:33 +0530 Subject: [PATCH 16/17] Printing path in the output log to help in analysis whether file exists in the path or not --- Unix/gen/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Unix/gen/main.cpp b/Unix/gen/main.cpp index 94470f58..15105a0c 100644 --- a/Unix/gen/main.cpp +++ b/Unix/gen/main.cpp @@ -420,7 +420,7 @@ static void _GetConfigFileOptions(GeneratorOptions& opts) /* Form the configuration file path */ if (FindConfigFile(path) != 0) - err("failed to find configuration file"); + err("failed to find configuration file: %s", path); /* Open the configuration file */ conf = Conf_Open(path); From a3a379205a700fc1e88c17784d62cc767b652fae Mon Sep 17 00:00:00 2001 From: gakamath Date: Tue, 28 Feb 2023 10:18:39 +0530 Subject: [PATCH 17/17] Adding a macro SUPPORT_KRB5 which enables us to choose whether to do Active Directory Auth or not Disabling this Macro allows user to do all operations with Basic auth. It will be useful in projects where Kerberos authentication will be costly or overkill. --- Unix/http/httpauth.c | 27 ++++++++++++++++++++++----- Unix/http/httpclientauth.c | 18 ++++++++++++++---- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/Unix/http/httpauth.c b/Unix/http/httpauth.c index c08c0147..efb97fb3 100644 --- a/Unix/http/httpauth.c +++ b/Unix/http/httpauth.c @@ -8,6 +8,7 @@ */ #include +#if defined SUPPORT_KRB5 #if ( AUTHORIZATION == 1 ) #if defined(macos) #include @@ -15,6 +16,7 @@ #include #endif #endif +#endif #include #include #include @@ -40,13 +42,16 @@ // #define ENCRYPT_DECRYPT 1 // #define AUTHORIZATION 1 +#if defined SUPPORT_KRB5 #if !defined(KRB5_CALLCOV) #define KRB5_CALLCONV #endif +#endif #define MAX_ERROR_STRING_SIZE 256 #define TIMESTAMP_SIZE 128 int GetTimeStamp(_Pre_writable_size_(TIMESTAMP_SIZE) char buf[TIMESTAMP_SIZE]); +#if defined SUPPORT_KRB5 static void _report_error(OM_uint32 major_status, OM_uint32 minor_status, const char *msg); // dlsyms from the dlopen @@ -169,7 +174,7 @@ static Gss_Extensions _g_gssState = { 0 }; static struct _Once g_once_state = ONCE_INITIALIZER; static const char GSS_LIBRARY_NAME[] = CONFIG_GSSLIB; - +#endif static const char RESPONSE_HEADER_UNAUTH_FMT[] = "HTTP/1.1 401 Unauthorized\r\n" "Content-Length: 0\r\n" "WWW-Authenticate: Basic realm=\"WSMAN\"\r\n" \ @@ -177,6 +182,7 @@ static const char RESPONSE_HEADER_UNAUTH_FMT[] = "WWW-Authenticate: Kerberos\r\n" "\r\n"; static const int RESPONSE_HEADER_UNAUTH_FMT_LEN = MI_COUNT(RESPONSE_HEADER_UNAUTH_FMT)-1; +#if defined SUPPORT_KRB5 void _GssUnloadLibrary() { dlclose(_g_gssState.libHandle); @@ -333,7 +339,7 @@ int _GssInitLibrary(_In_ void *data, _Outptr_result_maybenull_ void **value) return FALSE; } - +#endif #define HTTP_LONGEST_ERROR_DESCRIPTION 50 void _WriteTraceFile(PathID id, const void *data, size_t size); @@ -932,6 +938,7 @@ static void _SendAuthResponse(Http_SR_SocketData * sendSock, const char *pRespon } +#if defined SUPPORT_KRB5 #if AUTHORIZATION static gss_buffer_t _getPrincipalName(gss_ctx_id_t pContext) { @@ -1606,13 +1613,14 @@ static char *_BuildAuthResponse(_In_ const char *pProtocol, } #endif - +#endif void Deauthorize(_In_ Http_SR_SocketData * handler) { +#if defined SUPPORT_KRB5 #if defined(AUTHORIZATION) OM_uint32 maj_stat, min_stat; #endif - +#endif // Reinit all of the handler authorisation state. handler->authFailed = FALSE; @@ -1621,6 +1629,7 @@ void Deauthorize(_In_ Http_SR_SocketData * handler) { // Tear down the context. The function will set to null +#if defined SUPPORT_KRB5 #if defined(AUTHORIZATION) gss_ctx_id_t hdl = handler->pAuthContext; maj_stat = (* _g_gssState.Gss_Delete_Sec_Context)(&min_stat, &hdl, NULL); @@ -1630,11 +1639,14 @@ void Deauthorize(_In_ Http_SR_SocketData * handler) // I'm going to procede anyway. } handler->pAuthContext = hdl; +#endif #endif } if (handler->pVerifierCred) { +#if defined SUPPORT_KRB5 (* _g_gssState.Gss_Release_Cred)(&min_stat, handler->pVerifierCred); +#endif handler->pVerifierCred = NULL; } @@ -1731,7 +1743,9 @@ Http_CallbackResult IsClientAuthorized(_In_ Http_SR_SocketData * handler) #if AUTHORIZATION static const char RESPONSE_HEADER_BAD_REQUEST[] = "HTTP/1.1 400 Bad Request\r\n" "Content-Length: 0\r\n" "\r\n"; static const int RESPONSE_HEADER_BAD_REQUEST_LEN = MI_COUNT(RESPONSE_HEADER_BAD_REQUEST)-1; +#if defined SUPPORT_KRB5 OM_uint32 flags = 0; +#endif const char *protocol_p = NULL; #endif @@ -1843,6 +1857,7 @@ Http_CallbackResult IsClientAuthorized(_In_ Http_SR_SocketData * handler) handler->isAuthorised = TRUE; return PRT_RETURN_TRUE; } +#if defined SUPPORT_KRB5 #ifdef AUTHORIZATION else { @@ -2253,7 +2268,7 @@ Http_CallbackResult IsClientAuthorized(_In_ Http_SR_SocketData * handler) } } #endif - +#endif Done: return authorised; } @@ -2261,6 +2276,7 @@ Http_CallbackResult IsClientAuthorized(_In_ Http_SR_SocketData * handler) void HttpAuth_Close(_In_ Handler *handlerIn) { +#if defined SUPPORT_KRB5 Http_SR_SocketData* handler = FromOffset( Http_SR_SocketData, handler, handlerIn ); gss_ctx_id_t context_hdl = handler->pAuthContext; OM_uint32 min_stat = 0; @@ -2279,6 +2295,7 @@ void HttpAuth_Close(_In_ Handler *handlerIn) (*_g_gssState.Gss_Delete_Sec_Context)(&min_stat, &context_hdl, NULL); } } +#endif } MI_Result Process_Authorized_Message( diff --git a/Unix/http/httpclientauth.c b/Unix/http/httpclientauth.c index afb0d098..a9c14194 100644 --- a/Unix/http/httpclientauth.c +++ b/Unix/http/httpclientauth.c @@ -7,6 +7,7 @@ **============================================================================== */ #include +#if defined SUPPORT_KRB5 #if AUTHORIZATION #if defined(macos) #include @@ -15,6 +16,7 @@ #include #endif #endif +#endif #include #include #include @@ -260,6 +262,7 @@ typedef void KRB5_CALLCONV typedef enum { NOT_LOADED = 0, LOADING, LOADED } LoadState; +#if defined SUPPORT_KRB5 typedef struct _Gss_Extensions { LoadState gssLibLoaded; /* Default is NOT_LOADED */ @@ -326,6 +329,7 @@ MI_Boolean Gss_Oid_Equal(const gss_OID poid1, const gss_OID poid2) return MI_TRUE; } +#endif /* * Credentials are expected to live in the file ~/.omi/ntlmcred. @@ -559,6 +563,7 @@ _Success_(return == 0) int _ValidateClientCredentials(HttpClient_SR_SocketData * } +#if defined SUPPORT_KRB5 static void _GssUnloadLibrary(void) @@ -898,7 +903,7 @@ static _Success_(return == 0) int _GssClientInitLibrary( _In_ void* data, _Outpt _g_gssClientState.gssLibLoaded = NOT_LOADED; return FALSE; } - +#endif @@ -936,6 +941,7 @@ static int EncodePlaceCallback(const char *data, size_t size, void *callbackData return 0; } +#if defined SUPPORT_KRB5 #if AUTHORIZATION static void _getStatusMsg(OM_uint32 status_code, int status_type, gss_buffer_t statusString) @@ -1899,7 +1905,7 @@ static int _getInputToken(_In_ struct _HttpClient_SR_SocketData * self, const c } #endif - +#endif /* * Based on the authorisation type, we create an auth clause for the Http response header. * The response token is converted to base 64. @@ -2086,6 +2092,7 @@ static MI_Boolean _WriteAuthRequest(HttpClient_SR_SocketData * handler, const ch return TRUE; } +#if defined SUPPORT_KRB5 /* * Evaluates the response header returned by the server . * @@ -2693,7 +2700,7 @@ static char *_BuildInitialGssAuthHeader(_In_ HttpClient_SR_SocketData * self, MI } #endif - +#endif Http_CallbackResult HttpClient_RequestAuthorization(_In_ struct _HttpClient_SR_SocketData *handler, const char **pAuthHeader) { MI_Uint32 status = 0; @@ -2721,6 +2728,7 @@ Http_CallbackResult HttpClient_RequestAuthorization(_In_ struct _HttpClient_SR_S return PRT_CONTINUE; +#if defined SUPPORT_KRB5 #if AUTHORIZATION case AUTH_METHOD_NEGOTIATE_WITH_CREDS: case AUTH_METHOD_NEGOTIATE: @@ -2744,7 +2752,7 @@ Http_CallbackResult HttpClient_RequestAuthorization(_In_ struct _HttpClient_SR_S return PRT_CONTINUE; #endif - +#endif default: goto AuthFailed; } @@ -2871,6 +2879,7 @@ Http_CallbackResult HttpClient_IsAuthorized(_In_ struct _HttpClient_SR_SocketDat } +#if defined SUPPORT_KRB5 case AUTH_METHOD_NEGOTIATE_WITH_CREDS: case AUTH_METHOD_NEGOTIATE: case AUTH_METHOD_KERBEROS: @@ -3000,6 +3009,7 @@ Http_CallbackResult HttpClient_IsAuthorized(_In_ struct _HttpClient_SR_SocketDat #endif // unreachable return PRT_RETURN_FALSE; +#endif default: return PRT_RETURN_FALSE;