mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-06-07 00:38:20 +02:00
os/log: handle NULL string argument in vpnprintf
Since this function is called from signal handlers (e.g. OsSigHandler processing SIGSEGV/SIGBUS), a NULL %s argument triggers a recursive fault. Assisted-by: Claude:claude-claude-opus-4-6 Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2200>
This commit is contained in:
parent
c38037b11e
commit
75541aa42b
1 changed files with 3 additions and 1 deletions
4
os/log.c
4
os/log.c
|
|
@ -418,7 +418,7 @@ vpnprintf(char *string, int size_in, const char *f, va_list args)
|
|||
int f_idx = 0;
|
||||
int s_idx = 0;
|
||||
int f_len = strlen_sigsafe(f);
|
||||
char *string_arg;
|
||||
const char *string_arg;
|
||||
char number[21];
|
||||
int p_len;
|
||||
int i;
|
||||
|
|
@ -474,6 +474,8 @@ vpnprintf(char *string, int size_in, const char *f, va_list args)
|
|||
switch (f[f_idx]) {
|
||||
case 's':
|
||||
string_arg = va_arg(args, char*);
|
||||
if (!string_arg)
|
||||
string_arg = "(null)";
|
||||
|
||||
for (i = 0; string_arg[i] != 0 && s_idx < size - 1 && s_idx < precision; i++)
|
||||
string[s_idx++] = string_arg[i];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue