Skip to content

Commit c921645

Browse files
committed
fix signed shifts in raddbg_markup utf8 decoding; fix quoting of argument strings with spaces in command line target builds
1 parent b371bff commit c921645

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/lib_raddbg_markup/raddbg_markup.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ raddbg_decode_utf8(char *str, unsigned __int64 max)
170170
case 2:
171171
if(2 < max)
172172
{
173-
char cont_byte = str[1];
173+
unsigned char cont_byte = str[1];
174174
if(raddbg_utf8_class[cont_byte >> 3] == 0)
175175
{
176176
result.codepoint = (byte & 0x0000001f) << 6;
@@ -181,7 +181,7 @@ raddbg_decode_utf8(char *str, unsigned __int64 max)
181181
case 3:
182182
if(2 < max)
183183
{
184-
char cont_byte[2] = {str[1], str[2]};
184+
unsigned char cont_byte[2] = {str[1], str[2]};
185185
if(raddbg_utf8_class[cont_byte[0] >> 3] == 0 &&
186186
raddbg_utf8_class[cont_byte[1] >> 3] == 0)
187187
{
@@ -194,7 +194,7 @@ raddbg_decode_utf8(char *str, unsigned __int64 max)
194194
case 4:
195195
if(3 < max)
196196
{
197-
char cont_byte[3] = {str[1], str[2], str[3]};
197+
unsigned char cont_byte[3] = {str[1], str[2], str[3]};
198198
if(raddbg_utf8_class[cont_byte[0] >> 3] == 0 &&
199199
raddbg_utf8_class[cont_byte[1] >> 3] == 0 &&
200200
raddbg_utf8_class[cont_byte[2] >> 3] == 0)
@@ -431,6 +431,9 @@ raddbg_annotate_vaddr_range__impl(void *ptr, unsigned __int64 size, char *fmt, .
431431
va_list args;
432432
va_start(args, fmt);
433433
buffer_size = RADDBG_MARKUP_VSNPRINTF(buffer, sizeof(buffer), fmt, args);
434+
buffer_size = ((buffer_size < 0) ? 0 :
435+
(buffer_size > sizeof(buffer)) ? sizeof(buffer) :
436+
buffer_size);
434437
va_end(args);
435438
}
436439

src/raddbg/raddbg_core.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10028,7 +10028,14 @@ rd_init(CmdLine *cmdln)
1002810028
String8List passthrough_args_list = {0};
1002910029
for(String8Node *n = target_args.first->next; n != 0; n = n->next)
1003010030
{
10031-
str8_list_push(scratch.arena, &passthrough_args_list, n->string);
10031+
if(str8_find_needle(n->string, 0, str8_lit(" "), 0) < n->string.size)
10032+
{
10033+
str8_list_pushf(scratch.arena, &passthrough_args_list, "\"%S\"", escaped_from_raw_str8(scratch.arena, n->string));
10034+
}
10035+
else
10036+
{
10037+
str8_list_push(scratch.arena, &passthrough_args_list, n->string);
10038+
}
1003210039
}
1003310040
StringJoin join = {str8_lit(""), str8_lit(" "), str8_lit("")};
1003410041
arguments_string = str8_list_join(scratch.arena, &passthrough_args_list, &join);

0 commit comments

Comments
 (0)