[Bug] Account for all variadic format arguments

Aperta
#6 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c, cpp

Direzione di ricerca

Start with the argument-counting loop in src/decompiler/decompiler.cpp around lines 413-424, which counts one argument per conversion and ignores * and .*, then the hard-coded limits near lines 569-574 for fprintf, sprintf and snprintf. Build the reproducer printf("%*d\n", 5, 42) and check that recovery keeps both the width and the value. Done means the printf-family paths share one format-parsing routine, regression tests cover %*d, %.*f, multiple conversions and %%, and generated calls compile cleanly under -Wall -Wextra -Werror.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Summary

Variadic argument reconstruction undercounts format-driven arguments. The parser counts conversion specifiers but ignores * width/precision arguments, and several printf-family functions use hard-coded limits instead of parsing their format strings.

Evidence

src/decompiler/decompiler.cpp:413-424 increments the count once per conversion and does not account for * or .*. src/decompiler/decompiler.cpp:569-574 hard-codes limits for fprintf, sprintf, and snprintf.

Reproducer:

#include <stdio.h>
int main(void) {
    printf("%*d\n", 5, 42);
    return 0;
}

The recovered call is equivalent to:

printf(global_2004, 5);

It omits the value for %d; compiling with -Wall -Wextra -Werror reports format ‘%d’ expects a matching ‘int’ argument, and relaxed execution produces output different from the original.

Impact

Recovered calls to common variadic APIs can omit arguments, pass the wrong registers, or invoke undefined behavior. The issue affects width/precision stars, multiple conversions, and the hard-coded printf-family paths.

Expected behavior

Format parsing should account for every consumed argument: conversion values, * width, .* precision, positional forms, and the API-specific leading arguments for fprintf/sprintf/snprintf. When the format cannot be recovered confidently, output should preserve an explicit uncertainty rather than silently dropping registers.

Acceptance criteria

  • The reproducer preserves its padding and value after recovery.
  • printf, fprintf, sprintf, and snprintf use the same complete format-argument logic.
  • %*d, %.*f, multiple conversions, and escaped %% have regression coverage.
  • Generated calls compile without format diagnostics under -Wall -Wextra -Werror where the format is known.
Lingua principale
C++
Stelle
0
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TiElixir/caraxes

Tutte le issue di TiElixir/caraxes

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.