in src/fc_erd_argc_argv.c [129:216]
ARGC_ARGV_DATA_RESULT FABRIC_ENDPOINT_RESOURCE_DESCRIPTION_from_ARGC_ARGV(int argc, char** argv, FABRIC_ENDPOINT_RESOURCE_DESCRIPTION* fabric_endpoint_resource_description, int* argc_consumed)
{
ARGC_ARGV_DATA_RESULT result;
if (
(argc < 6) ||
(argv == NULL) ||
(fabric_endpoint_resource_description == NULL) ||
(argc_consumed == NULL)
)
{
LogError("invalid argument int argc=%d, char** argv=%p, FABRIC_ENDPOINT_RESOURCE_DESCRIPTION* fabric_endpoint_resource_description=%p, int* argc_consumed=%p",
argc, argv, fabric_endpoint_resource_description, argc_consumed);
result = ARGC_ARGV_DATA_INVALID;
}
else
{
if (strcmp(argv[0], SERVICE_ENDPOINT_RESOURCE) != 0)
{
LogError("cannot parse %s as FABRIC_ENDPOINT_RESOURCE_DESCRIPTION (it was expected to be " SERVICE_ENDPOINT_RESOURCE "", argv[0]);
result = ARGC_ARGV_DATA_INVALID;
}
else
{
char* stop;
errno = 0;
uint64_t port = strtoull(argv[4], &stop, 10);
if (
(port > UINT16_MAX) || /*note: overflow always returns ULLONG_MAX which is clearly greater than UINT16_MAX*/
(stop[0]!='\0')
)
{
LogError("scanning of Port=%s failed. Returned value was=%" PRIu64 ", scanning stopped at \"%s\" after %zu characters, errno was=%d (%s)", argv[4], port, stop, stop - argv[4], errno, strerror(errno));
result = ARGC_ARGV_DATA_INVALID;
}
else
{
fabric_endpoint_resource_description->Port = (uint16_t)port; /*weird how endpoint description in SF uses "unsigned long" for port... which not even IPV6 changes...*/
fabric_endpoint_resource_description->Name = mbs_to_wcs(argv[1]);
if (fabric_endpoint_resource_description->Name == NULL)
{
LogError("failure in mbs_to_wcs");
result = ARGC_ARGV_DATA_ERROR;
}
else
{
fabric_endpoint_resource_description->Protocol = mbs_to_wcs(argv[2]);
if (fabric_endpoint_resource_description->Protocol == NULL)
{
LogError("failure in mbs_to_wcs");
result = ARGC_ARGV_DATA_ERROR;
}
else
{
fabric_endpoint_resource_description->Type = mbs_to_wcs(argv[3]);
if (fabric_endpoint_resource_description->Type == NULL)
{
LogError("failure in mbs_to_wcs");
result = ARGC_ARGV_DATA_ERROR;
}
else
{
fabric_endpoint_resource_description->CertificateName = mbs_to_wcs(argv[5]);
if (fabric_endpoint_resource_description->CertificateName == NULL)
{
LogError("failure in mbs_to_wcs");
result = ARGC_ARGV_DATA_ERROR;
}
else
{
fabric_endpoint_resource_description->Reserved = NULL;
*argc_consumed = 6;
result = ARGC_ARGV_DATA_OK;
goto allok;
//free(fabric_endpoint_resource_description->CertificateName);
}
free((void*)fabric_endpoint_resource_description->Type);
}
free((void*)fabric_endpoint_resource_description->Protocol);
}
free((void*)fabric_endpoint_resource_description->Name);
}
}
}
}
allok:;
return result;
}