fix: fallback key in multi-key mode + bound printf context

- decrypt_images.c: try image_keys.json lookup first, fall back to
  config.json single key when CT pattern not mapped (previously returned
  -5 immediately in multi-key mode)
- find_image_key.c: cap ASCII context printf to remaining buffer length,
  preventing out-of-bounds read near region end
This commit is contained in:
bbingz
2026-03-05 23:28:07 +08:00
committed by ylytdeng
parent 96c1a5ac2e
commit e84f1d5130
2 changed files with 11 additions and 10 deletions

View File

@@ -470,8 +470,10 @@ static int scan_pid(pid_t pid) {
printf("\n *** FOUND KEY: %s ***\n", kh);
printf(" Pattern: %s (%d files)\n",
ch, patterns[idx].file_count);
printf(" ASCII context: %.32s\n",
buf + run_start);
int ctx_len = data_cnt - run_start;
if (ctx_len > 32) ctx_len = 32;
printf(" ASCII context: %.*s\n",
ctx_len, buf + run_start);
found_this_pid++;
/* Rebuild */
n_unsolved = 0;