`u -uq3` (anti-item action) on zip and tar silently stores the deleted file as an empty regular file; 7z stores a real anti-item

Abierto
#293 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
65/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
cpp
Área
backend

Línea de trabajo

Start with UpdateCallback.cpp:483-494 and :601-621 to see how anti items reach the format handlers, then compare Archive/7z/7zHandlerOut.cpp:555 with the zip and tar handlers. Reproduce with the supplied commands for zip and tar. Done when the update no longer stores or extracts a deleted item as a zero-byte file, while 7z behavior remains as documented.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Environment

7-Zip (z) 26.06 (arm64), ip7z/7zip @ d3296e3, macOS 26.4.1 arm64

Steps to reproduce
d=$(mktemp -d) && cd "$d"
for t in 7z zip tar; do
  rm -rf w xo; mkdir w; cd w
  printf aaa > keep.txt; printf bbb > gone.txt
  7zz a -bd -t$t ../x.$t keep.txt gone.txt > /dev/null
  rm gone.txt                                  # file disappears from disk
  7zz u -bd -uq3 ../x.$t keep.txt gone.txt > /dev/null 2>&1   # q3: item only in archive -> anti-item
  cd ..
  echo "== $t"; 7zz l -slt x.$t | grep -E '^(Path|Size|Anti) =' | tail -n +2 | tr '\n' ' '; echo
  7zz x -y -bd -oxo x.$t > /dev/null 2>&1; echo "extracted: $(ls xo | tr '\n' ' ')"
  rm -f x.$t
done

Output:

== 7z    gone.txt Size=0 Anti=+   keep.txt Size=3 Anti=-     extracted: keep.txt
== zip   gone.txt Size=0          keep.txt Size=3            extracted: gone.txt keep.txt
== tar   gone.txt Size=0          keep.txt Size=3            extracted: gone.txt keep.txt

(The u command itself returns 1 because gone.txt is missing on disk; the same happens for 7z.)

Expected

The -u documentation says of action 3 ("Create Anti-item"): "This feature is supported only in 7z format." So for zip and tar the update action should be rejected with an error (or ignored). Either the update action is rejected for formats that cannot represent anti-items, or the archive does not contain gone.txt at all. The archive should not contain a 0-byte file that was never on disk, and extraction should not create it.

Actual

For zip and tar, gone.txt becomes a regular 0-byte entry and is created by extraction. 7z keeps a real anti-item (Anti = +) that is not extracted.

Root cause (analysis on d3296e3)

UpdateCallback.cpp:483-494 and :601-621 report such items to the format handler with size 0 and kpidIsAnti. Only Archive/7z/7zHandlerOut.cpp:555 queries kpidIsAnti. The zip and tar handlers never read it and write the item as a normal empty file.

Suggested fix

In the zip and tar handlers, skip anti items (or fail the update with a clear message) instead of writing an empty file.


Found with a differential test setup (a model of the documented behavior compared against the real binary) and then checked by hand: every command above was re-run verbatim on the tested build, and the root cause was read in the source. Tested commit: d3296e3 (26.06).

Lenguaje dominante
C++
Estrellas
4.6k
Forks
519
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ip7z/7zip

Todos los issues de ip7z/7zip

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.