[winpr,utils] fix integer narrow

This commit is contained in:
akallabeth 2024-09-25 02:50:19 +02:00
parent 4a0f996d42
commit 8a042b33d6
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5
2 changed files with 15 additions and 12 deletions

View File

@ -59,13 +59,11 @@ int CommandLineParseArgumentsA(int argc, LPSTR* argv, COMMAND_LINE_ARGUMENT_A* o
{
int status = 0;
int count = 0;
size_t length = 0;
BOOL notescaped = FALSE;
const char* sigil = NULL;
size_t sigil_length = 0;
char* keyword = NULL;
size_t keyword_length = 0;
SSIZE_T keyword_index = 0;
size_t keyword_index = 0;
char* separator = NULL;
char* value = NULL;
int toggle = 0;
@ -85,6 +83,7 @@ int CommandLineParseArgumentsA(int argc, LPSTR* argv, COMMAND_LINE_ARGUMENT_A* o
for (int i = 1; i < argc; i++)
{
size_t keyword_length = 0;
BOOL found = FALSE;
BOOL escaped = TRUE;
@ -108,7 +107,7 @@ int CommandLineParseArgumentsA(int argc, LPSTR* argv, COMMAND_LINE_ARGUMENT_A* o
}
sigil = argv[i];
length = strlen(argv[i]);
size_t length = strlen(argv[i]);
if ((sigil[0] == '/') && (flags & COMMAND_LINE_SIGIL_SLASH))
{
@ -202,14 +201,20 @@ int CommandLineParseArgumentsA(int argc, LPSTR* argv, COMMAND_LINE_ARGUMENT_A* o
}
else
{
keyword_length = (length - keyword_index);
if (length < keyword_index)
{
log_error(flags, "Failed at index %d [%s]: Argument required", i, argv[i]);
return COMMAND_LINE_ERROR;
}
keyword_length = length - keyword_index;
value = NULL;
}
if (!escaped)
continue;
for (int j = 0; options[j].Name != NULL; j++)
for (size_t j = 0; options[j].Name != NULL; j++)
{
COMMAND_LINE_ARGUMENT_A* cur = &options[j];
BOOL match = FALSE;

View File

@ -5,16 +5,14 @@
int TestArrayList(int argc, char* argv[])
{
SSIZE_T count = 0;
SSIZE_T rc = 0;
size_t val = 0;
wArrayList* arrayList = NULL;
const size_t elemsToInsert = 10;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
arrayList = ArrayList_New(TRUE);
wArrayList* arrayList = ArrayList_New(TRUE);
if (!arrayList)
return -1;
@ -24,9 +22,9 @@ int TestArrayList(int argc, char* argv[])
return -1;
}
count = ArrayList_Count(arrayList);
size_t count = ArrayList_Count(arrayList);
printf("ArrayList count: %d\n", count);
printf("ArrayList count: %" PRIuz "\n", count);
SSIZE_T index = ArrayList_IndexOf(arrayList, (void*)(size_t)6, -1, -1);
@ -71,7 +69,7 @@ int TestArrayList(int argc, char* argv[])
return -1;
count = ArrayList_Count(arrayList);
printf("ArrayList count: %d\n", count);
printf("ArrayList count: %" PRIuz "\n", count);
if (count != 0)
return -1;