mirror of
https://github.com/CTCaer/hekate
synced 2024-11-16 00:49:27 +00:00
bdk: fatfs: check if string is null for puts/printf
Avoid writing garbage to a file by checking string pointer passed to f_puts and f_printf. Important on many embedded platforms that do not abort on NULL dereference.
This commit is contained in:
parent
e31d6446db
commit
99d15eaac8
1 changed files with 6 additions and 2 deletions
|
@ -4712,9 +4712,9 @@ DWORD *f_expand_cltbl (
|
|||
}
|
||||
if (f_lseek(fp, CREATE_LINKMAP)) { /* Create cluster link table */
|
||||
ff_memfree(fp->cltbl);
|
||||
fp->cltbl = NULL;
|
||||
fp->cltbl = (void *)0;
|
||||
EFSPRINTF("CLTBLSZ");
|
||||
return NULL;
|
||||
return (void *)0;
|
||||
}
|
||||
f_lseek(fp, 0);
|
||||
|
||||
|
@ -6737,6 +6737,8 @@ int f_puts (
|
|||
putbuff pb;
|
||||
|
||||
|
||||
if (str == (void *)0) return EOF; /* String is NULL */
|
||||
|
||||
putc_init(&pb, fp);
|
||||
while (*str) putc_bfd(&pb, *str++); /* Put the string */
|
||||
return putc_flush(&pb);
|
||||
|
@ -6763,6 +6765,8 @@ int f_printf (
|
|||
TCHAR c, d, str[32], *p;
|
||||
|
||||
|
||||
if (fmt == (void *)0) return EOF; /* String is NULL */
|
||||
|
||||
putc_init(&pb, fp);
|
||||
|
||||
va_start(arp, fmt);
|
||||
|
|
Loading…
Reference in a new issue