瀏覽代碼

Fix off-by-one memory read in binary canvas import (fixes #56, #58)

tags/v0.99.beta20
Sam Hocevar 3 年之前
父節點
當前提交
b4b4a473cd
共有 1 個檔案被更改,包括 4 行新增1 行删除
  1. +4
    -1
      caca/codec/import.c

+ 4
- 1
caca/codec/import.c 查看文件

@@ -420,6 +420,9 @@ ssize_t _import_bin(caca_canvas_t *cv, void const *data, size_t len)
caca_set_canvas_size(cv, 0, 0);
caca_set_canvas_size(cv, 160, len / 160);

/* Only read an even number of bytes */
len &= ~(size_t)1;

for (i = 0; i < len; i += 2)
{
caca_set_color_ansi(cv, buf[i + 1] & 0xf, buf[i + 1] >> 4);
@@ -433,6 +436,6 @@ ssize_t _import_bin(caca_canvas_t *cv, void const *data, size_t len)
}
}

return len & ~(size_t)1;
return len;
}


Loading…
取消
儲存