]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
aft: Always copy and compare full hash value.
authorAndre Noll <maan@tuebingen.mpg.de>
Mon, 30 Jan 2023 14:10:32 +0000 (15:10 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 20 Feb 2023 12:48:05 +0000 (13:48 +0100)
Although we switched to 32 byte hash function in paraslash-0.7.0,
we kept comparing only the first 20 bytes to verify that the file
has not changed. Also the ls output and the status items contained
only the first 20 bytes of the hash value.

aft.c

diff --git a/aft.c b/aft.c
index 4fb60f91687e96a67e0169a1d3eeecf97f272bd1..b4d8c2dd359bbfbe143c8be75a89b016b0bfe505 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -913,7 +913,7 @@ static int print_list_item(struct ls_data *d, struct ls_options *opts,
                goto out;
        write_image_items(b, afsi);
        write_lyrics_items(b, afsi);
-       hash_to_asc(d->hash, asc_hash);
+       hash2_to_asc(d->hash, asc_hash);
        WRITE_STATUS_ITEM(b, SI_hash, "%s\n", asc_hash);
        WRITE_STATUS_ITEM(b, SI_bitrate, "%dkbit/s\n", afhi->bitrate);
        WRITE_STATUS_ITEM(b, SI_format, "%s\n",
@@ -1067,8 +1067,8 @@ again:
        if (ret < 0)
                return ret;
        if (!d->hash)
-               d->hash = alloc(HASH_SIZE);
-       memcpy(d->hash, tmp_hash, HASH_SIZE);
+               d->hash = alloc(HASH2_SIZE);
+       memcpy(d->hash, tmp_hash, HASH2_SIZE);
        free(d->path);
        ret = get_audio_file_path_of_row(current_aft_row, &d->path);
        if (ret < 0)
@@ -1102,7 +1102,7 @@ again:
        if (ret < 0)
                goto out;
        hash2_function(map.data, map.size, file_hash);
-       ret = hash_compare(file_hash, d->hash);
+       ret = hash2_compare(file_hash, d->hash);
        para_munmap(map.data, map.size);
        if (ret) {
                ret = -E_HASH_MISMATCH;
@@ -1651,7 +1651,7 @@ static int com_add_callback(struct afs_callback_arg *aca)
        r_v = SERVER_CMD_OPT_RESULT(ADD, VERBOSE, aca->lpr);
 
        hash = (unsigned char *)buf + CAB_HASH_OFFSET;
-       hash_to_asc(hash, asc);
+       hash2_to_asc(hash, asc);
        objs[AFTCOL_HASH].data = buf + CAB_HASH_OFFSET;
        objs[AFTCOL_HASH].size = HASH2_SIZE;
 
@@ -1722,7 +1722,7 @@ static int com_add_callback(struct afs_callback_arg *aca)
                ret = get_hash_of_row(pb, &old_hash);
                if (ret < 0)
                        goto out;
-               hash_to_asc(old_hash, old_asc);
+               hash2_to_asc(old_hash, old_asc);
                if (lls_opt_given(r_v))
                        para_printf(&aca->pbout, "file change: %s -> %s\n",
                                old_asc, asc);