mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +01:00
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 <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
546c148ac0
commit
51ad8b7dc1
@@ -90,13 +90,10 @@ char *wdefaultspathfordomain(const char *domain)
|
|||||||
slen = strlen(gspath) + strlen(DEFAULTS_DIR) + strlen(domain) + 4;
|
slen = strlen(gspath) + strlen(DEFAULTS_DIR) + strlen(domain) + 4;
|
||||||
path = wmalloc(slen);
|
path = wmalloc(slen);
|
||||||
|
|
||||||
if (wstrlcpy(path, gspath, slen) >= slen ||
|
strcpy(path, gspath);
|
||||||
wstrlcat(path, DEFAULTS_DIR, slen) >= slen ||
|
strcat(path, DEFAULTS_DIR);
|
||||||
wstrlcat(path, "/", slen) >= slen ||
|
strcat(path, "/");
|
||||||
wstrlcat(path, domain, slen) >= slen) {
|
strcat(path, domain);
|
||||||
wfree(path);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -823,23 +823,14 @@ static char *getCurrentFileName(WMFilePanel * panel)
|
|||||||
slen = strlen(path) + strlen(file) + 1;
|
slen = strlen(path) + strlen(file) + 1;
|
||||||
ret = wmalloc(slen);
|
ret = wmalloc(slen);
|
||||||
|
|
||||||
if (*file != '/' &&
|
if (file[0] != '/')
|
||||||
wstrlcat(ret, path, slen) >= slen)
|
strcpy(ret, path);
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (wstrlcat(ret, file, slen) >= slen)
|
strcat(ret, file);
|
||||||
goto error;
|
|
||||||
|
|
||||||
wfree(file);
|
wfree(file);
|
||||||
wfree(path);
|
wfree(path);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
error:
|
|
||||||
wfree(file);
|
|
||||||
wfree(path);
|
|
||||||
wfree(ret);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user