Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 00087b70 authored by Greg Kaiser's avatar Greg Kaiser
Browse files

installd: Avoid potential use of null 'src'.

In create_cache_path, we have code checking whether 'src' is null,
implying it's possibile it could be null here.  To be safe, we move
our strlen call until after this check.

Change-Id: I6a67cdad8ebf8bdce1562ce5f0cbf98b084807ef
parent e0df6e9d
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -128,13 +128,13 @@ bool calculate_odex_file_path(char path[PKG_PATH_MAX],
bool create_cache_path(char path[PKG_PATH_MAX],
                       const char *src,
                       const char *instruction_set) {
    size_t srclen = strlen(src);

    /* demand that we are an absolute path */
    if ((src == 0) || (src[0] != '/') || strstr(src,"..")) {
    if ((src == nullptr) || (src[0] != '/') || strstr(src,"..")) {
        return false;
    }

    size_t srclen = strlen(src);

    if (srclen > PKG_PATH_MAX) {        // XXX: PKG_NAME_MAX?
        return false;
    }