From: Andre Noll Date: Mon, 30 Jan 2023 14:10:32 +0000 (+0100) Subject: aft: Always copy and compare full hash value. X-Git-Tag: v0.7.2~3 X-Git-Url: http://git.tuebingen.mpg.de/releases/paraslash-0.2.10.tar.bz2?a=commitdiff_plain;h=84d9cbacb56da678d687402a4ec4d0b3094c974a;p=paraslash.git aft: Always copy and compare full hash value. 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. --- diff --git a/aft.c b/aft.c index 4fb60f91..b4d8c2dd 100644 --- 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);