Кресты / Говнокод #18788 Ссылка на оригинал

0

  1. 1
TBufferedFileInput storage(sprintf("%s", path));

Весьма оригинальный способ приведения типа к самому себе.

Запостил: skyhawk skyhawk, (Updated )

Комментарии (16) RSS

  • int sprintf ( char * str, const char * format, ... );
    Parameters
    str
    Pointer to a buffer where the resulting C-string is stored.
    The buffer should be large enough to contain the resulting string.
    format
    C string that contains a format string that follows the same specifications as format in printf (see printf for details).
    ... (additional arguments)
    Depending on the format string, the function may expect a sequence of additional arguments, each containing a value to be used to replace a format specifier in the format string (or a pointer to a storage location, for n).
    There should be at least as many of these arguments as the number of values specified in the format specifiers. Additional arguments are ignored by the function.
    Return Value
    On success, the total number of characters written is returned. This count does not include the additional null-character automatically appended at the end of the string.
    On failure, a negative number is returned.

    Хуета какая-то.
    Ответить
    • Да это же дабл UB!

      1) Воспользовавшись path как строкой формата прочитали хуй знает какие данные со стека (если в нём были процентики)
      2) Попытались высрать результат прямо поверх литерала "%s".

      P.S. Но кто сказал, что это именно ::sprintf, а не какой-нибудь кастомный TSomeShit::sprintf?
      Ответить
  • Гугление показало, что тип TBufferedFileInput используется в томита-парсере от яндекса. Также там есть тип Stroka.
    Ответить

Добавить комментарий

Я, guest, находясь в здравом уме и твердой памяти, торжественно заявляю:

    А не использовать ли нам bbcode?


    8