From 09e241fb1271021e3615512debd3136891547562 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Thu, 27 Jul 2017 16:07:50 -0300 Subject: Security review: check results of snprintf. Calls marked with xSnprintf shouldn't fail. Abort program cleanly if any of them does. --- OpenFilesScreen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenFilesScreen.c') diff --git a/OpenFilesScreen.c b/OpenFilesScreen.c index 75190fe1..a772bbac 100644 --- a/OpenFilesScreen.c +++ b/OpenFilesScreen.c @@ -77,7 +77,7 @@ void OpenFilesScreen_draw(InfoScreen* this) { static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) { char command[1025]; - snprintf(command, 1024, "lsof -P -p %d -F 2> /dev/null", pid); + xSnprintf(command, 1024, "lsof -P -p %d -F 2> /dev/null", pid); FILE* fd = popen(command, "r"); OpenFiles_ProcessData* pdata = xCalloc(1, sizeof(OpenFiles_ProcessData)); OpenFiles_FileData* fdata = NULL; @@ -131,7 +131,7 @@ void OpenFilesScreen_scan(InfoScreen* this) { int lenN = data['n'] ? strlen(data['n']) : 0; int sizeEntry = 5 + 7 + 10 + 10 + 10 + lenN + 5 /*spaces*/ + 1 /*null*/; char* entry = xMalloc(sizeEntry); - snprintf(entry, sizeEntry, "%5.5s %7.7s %10.10s %10.10s %10.10s %s", + xSnprintf(entry, sizeEntry, "%5.5s %7.7s %10.10s %10.10s %10.10s %s", data['f'] ? data['f'] : "", data['t'] ? data['t'] : "", data['D'] ? data['D'] : "", -- cgit v1.2.3