From 51ad8b7dc1e9299c58675b650ccb17ab625fa0f2 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Fri, 9 May 2014 21:29:09 +0200 Subject: [PATCH] WINGs: Removed checks for code that can't fail In the function 'wdefaultspathfordomain' there was a check to make sure the generated path would fit in the allocated area, but this allocated area is sized precisely to fit the path, so it cannot fail. In the function 'getCurrentFileName' there were checks to make sure the generated result string would fit in the allocated area, but this allocated area is sized precisely to fit the path, so it cannot fail. Signed-off-by: Christophe CURIS --- WINGs/userdefaults.c | 11 ++++------- WINGs/wfilepanel.c | 15 +++------------ 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/WINGs/userdefaults.c b/WINGs/userdefaults.c index 876371d8..6b55e8cf 100644 --- a/WINGs/userdefaults.c +++ b/WINGs/userdefaults.c @@ -90,13 +90,10 @@ char *wdefaultspathfordomain(const char *domain) slen = strlen(gspath) + strlen(DEFAULTS_DIR) + strlen(domain) + 4; path = wmalloc(slen); - if (wstrlcpy(path, gspath, slen) >= slen || - wstrlcat(path, DEFAULTS_DIR, slen) >= slen || - wstrlcat(path, "/", slen) >= slen || - wstrlcat(path, domain, slen) >= slen) { - wfree(path); - return NULL; - } + strcpy(path, gspath); + strcat(path, DEFAULTS_DIR); + strcat(path, "/"); + strcat(path, domain); return path; } diff --git a/WINGs/wfilepanel.c b/WINGs/wfilepanel.c index 6dc8babb..0f128195 100644 --- a/WINGs/wfilepanel.c +++ b/WINGs/wfilepanel.c @@ -823,23 +823,14 @@ static char *getCurrentFileName(WMFilePanel * panel) slen = strlen(path) + strlen(file) + 1; ret = wmalloc(slen); - if (*file != '/' && - wstrlcat(ret, path, slen) >= slen) - goto error; + if (file[0] != '/') + strcpy(ret, path); - if (wstrlcat(ret, file, slen) >= slen) - goto error; + strcat(ret, file); wfree(file); wfree(path); return ret; - -error: - wfree(file); - wfree(path); - wfree(ret); - - return NULL; }