diff --git a/bypy/linux/launcher.c b/bypy/linux/launcher.c index fc9cbbf7c6..77088353c3 100644 --- a/bypy/linux/launcher.c +++ b/bypy/linux/launcher.c @@ -26,16 +26,21 @@ int main(int argc, char **argv) { } strncpy(lib, buf, PATHLEN); strncpy(base, dirname(lib), PATHLEN); - snprintf(exe, PATHLEN, "%s/bin/%s", base, basename(buf)); + int ret = snprintf(exe, PATHLEN, "%s/bin/%s", base, basename(buf)); + if (ret < 0 || ret > (PATHLEN-2)) { fprintf(stderr, "Path to executable too long: %s/bin/%s", base, basename(buf)); return 1; } memset(lib, 0, PATHLEN); - snprintf(lib, PATHLEN, "%s/lib", base); + ret = snprintf(lib, PATHLEN, "%s/lib", base); + if (ret < 0 || ret > (PATHLEN-2)) { fprintf(stderr, "Path to lib too long: %s/lib", base); return 1; } SET("CALIBRE_QT_PREFIX", base) memset(buf, 0, PATHLEN); ldp = getenv("LD_LIBRARY_PATH"); if (ldp == NULL) strncpy(buf, lib, PATHLEN); - else snprintf(buf, PATHLEN, "%s:%s", lib, ldp); + else { + ret = snprintf(buf, PATHLEN, "%s:%s", lib, ldp); + if (ret < 0 || ret > (PATHLEN-2)) { fprintf(stderr, "LD_LIBRARY_PATH too long: %s:%s", lib, ldp); return 1; } + } SET("LD_LIBRARY_PATH", buf) argv[0] = exe;