Exemplo n.º 1
0
char *hash2dirname(const char *hash)
{
    unsigned hash_len = strlen(hash);
    if (!isxdigit_str(hash) || hash_len < 5)
        return NULL;

    /* Try loading by dirname hash */
    struct name_resolution_param param = { hash, hash_len, NULL };
    GList *dir_list = get_problem_storages();
    for (GList *li = dir_list; li; li = li->next)
        for_each_problem_in_dir(li->data, getuid(), find_dir_by_hash, &param);
    return param.found_name;
}
Exemplo n.º 2
0
char *find_problem_by_hash(const char *hash, GList *problems)
{
    unsigned hash_len = strlen(hash);
    if (!isxdigit_str(hash) || hash_len < 5)
        return NULL;

    char *found_name = NULL;
    for (GList *iter = problems; iter; iter = g_list_next(iter))
    {
        char hash_str[SHA1_RESULT_LEN*2 + 1];
        str_to_sha1str(hash_str, (const char *)(iter->data));
        if (strncasecmp(hash, hash_str, hash_len) == 0)
        {
            if (found_name)
                error_msg_and_die(_("'%s' identifies more than one problem directory"), hash);
            found_name = xstrdup((const char *)(iter->data));
        }
    }

    return found_name;
}