mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-13 20:44:35 +03:00
Security review: check results of snprintf.
Calls marked with xSnprintf shouldn't fail. Abort program cleanly if any of them does.
This commit is contained in:
4
XAlloc.c
4
XAlloc.c
@ -5,11 +5,11 @@
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include <err.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/*{
|
||||
#include <err.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
}*/
|
||||
@ -44,6 +44,8 @@ void* xRealloc(void* ptr, size_t size) {
|
||||
return data;
|
||||
}
|
||||
|
||||
#define xSnprintf(fmt, len, ...) do { int _l=len; int _n=snprintf(fmt, _l, __VA_ARGS__); if (!(_n > -1 && _n < _l)) { curs_set(1); endwin(); err(1, NULL); } } while(0)
|
||||
|
||||
#undef xStrdup
|
||||
#undef xStrdup_
|
||||
#ifdef NDEBUG
|
||||
|
Reference in New Issue
Block a user