aboutsummaryrefslogtreecommitdiff
path: root/libc/stdio
AgeCommit message (Collapse)AuthorFilesLines
2017-02-02libc/stdio/vsnprintf.c: add explicit fallthroughStewart Smith1-0/+1
silences recent GCC warning Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-10-11libc : Changes variable data type where return value of strlen() stored from ↵Mukesh Ojha1-2/+2
int to size_t Reason of the change as integer value may overflow, and it can give negative value for the length. This patch also changes the data type of variable which is compared with strlen() as the comparison also has to be done on the same level. Signed-off-by: Mukesh Ojha <mukesh02@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-07-18libc: Remove NULL check for format argument in snprintf()Cyril Bur1-1/+1
libc printf style functions are annotated with __attribute__((format (printf, x, y))) which causes GCC to perform compile time checks against these arguments. As of at least gcc 6.1.1 [(GCC) 6.1.1 20160602] this causes an error running make check. GCC appears to be guaranteeing that the format argument won't be NULL and complaining about explicit checks. In file included from core/test/run-console-log-buf-overrun.c:48:0: core/test/run-console-log-buf-overrun.c: In function ‘snprintf’: core/test/../../libc/stdio/snprintf.c:21:19: error: nonnull argument ‘format’compared to NULL [-Werror=nonnull-compare] if ((buff==NULL) || (format==NULL)) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make: *** [core/test/Makefile.check:59:core/test/run-console-log-buf-overrun] Error 1 Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-06-20Fix for typosFrederic Bonnard1-1/+1
While reviewing the Debian packaging, codespell found those. Most proposed fixes are based on codespell's default dictionnary. Signed-off-by: Frederic Bonnard <frediz@linux.vnet.ibm.com> Reviewed-by: Mukesh Ojha <mukesh02@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-11-13Remove unused scanf and variantsStewart Smith5-455/+3
We don't use scanf at all, so solve the bugs found by static analysis by just removing it. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-01-19Merge branch 'update-2.1.1.1'Stewart Smith1-55/+108
2015-01-19opal: Fix buffer overrun in print_* functions.skiboot-2.1.1-fw810.20-4Mahesh Salgaonkar1-55/+108
While running HMI tests I saw a massive corruption in OPAL for one of the HMI test that injects TB error. On investigation I found that vsnprintf()->print_itoa() was the culprit. print_itoa function uses tmp array of size 16 to convert unsigned long value to ASCII. But an unsigned value of 0xffffffffffffffff needs atleast 25 characters to print its ASCII representation. This caused an array to overflow resulting into corruption, unpredictable behavior and finally system termination. We could fix this by increasing the size of tmp[] array but that still won't fix this bug completely. While auditing vsnprintf() function I found that it makes use of print_*() functions to write data to buffer. But none of the print_* function have any check on buffer size before writing data to it. Without size check print_*() can easily overrun buffer passed by vprlog()->vsnprintf()->print_format()->print_*() causing massive corruption leading to unpredictable behavior. This patch fixes this bug by modifying print_*() function to check for buffer size to avoid buffer overrun. - Modified print_format(), print_fill() and print_itoa() to take bufsize as argument and added a size check while writing to buffer. - Remove temporary array from print_itoa(), instead write data directly to buffer. - Added two new function print_str_fill() and print_str() to be used as helper routine for '%s' fmt case in print_format() function. These new routines now has a check on buffer size while copying NULL terminated string to buffer. - Added "!bufsize" check in vsnprintf() to avoid buffer overrun while setting NULL character before returning. I ran HMI tests with this patch successfully. I also tested this patch by reducing size of the buffer (in core/console-log.c:vprlog()) from 320 to 50 and booted the lid successfully with no corruption at all. Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> Acked-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-11-28Remove vsprintf: just like sprintf, vsnprintf is a much better ideaStewart Smith2-20/+1
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-11-28Remove sprintf: there's no good reason to have this in firmwareStewart Smith2-31/+1
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-11-26vsnprintf: Change print_itoa to use less stackShreyas B. Prabhu1-9/+9
Remove recursive call in print_itoa to reduce the stack usage. Signed-off-by: Shreyas B. Prabhu <shreyas@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-08-08replace printf() with console log, level 5 aka INFO messagesStewart Smith2-28/+1
Replace the libc printf implementation with a wrapper that does fancy log things such as display timestamp and the log level. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-07-02Initial commit of Open Source releaseBenjamin Herrenschmidt19-0/+1043
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>