From 02b11c1982427e9c8593e11a36319aca30fe1f34 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Thu, 5 Jan 2017 16:48:44 -0500 Subject: [PATCH] LegacyPackageInstaller: Fix strnlen/strncmp usage. I should have my "License to C" revoked... --- src/apps/packageinstaller/UninstallView.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apps/packageinstaller/UninstallView.cpp b/src/apps/packageinstaller/UninstallView.cpp index ba6fba49e1..e3fc522ec4 100644 --- a/src/apps/packageinstaller/UninstallView.cpp +++ b/src/apps/packageinstaller/UninstallView.cpp @@ -361,8 +361,8 @@ UninstallView::_ReloadAppList() if (iter.GetNodeRef(&ref) != B_OK) continue; - if (strncmp(filename + (strnlen(filename, B_FILE_NAME_LENGTH) - 3), - "pdb", 3) != 0) { + size_t len = strnlen(filename, B_FILE_NAME_LENGTH); + if (len < 3 || strncmp(filename + (len - 3), "pdb", 3) != 0) { printf("Ignoring non-package '%s'\n", filename); continue; }