diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2017-07-27 16:07:50 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2017-07-27 16:07:50 -0300 |
commit | 09e241fb1271021e3615512debd3136891547562 (patch) | |
tree | 8245b6084607a34185cfa7d3d45f5228937020f1 /OpenFilesScreen.c | |
parent | 3975e9ce5cba0e3972b2ddab28c198e000441501 (diff) |
Security review: check results of snprintf.
Calls marked with xSnprintf shouldn't fail.
Abort program cleanly if any of them does.
Diffstat (limited to 'OpenFilesScreen.c')
-rw-r--r-- | OpenFilesScreen.c | 4 |
1 files changed, 2 insertions, 2 deletions
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'] : "", |