[PATCH] blktrace: fix for potential data overwrite
authorAlan D. Brunelle <Alan.Brunelle@hp.com>
Tue, 24 Jan 2006 18:08:05 +0000 (19:08 +0100)
committerJens Axboe <axboe@suse.de>
Tue, 24 Jan 2006 18:08:05 +0000 (19:08 +0100)
commit0685312fdd24afa24ebfa9746f65baa0797b56a1
treebf137de087ca86826bebf403f697cd486f80f13f
parentf4f763cab2ef0210088e35c336f217293222ee7b
[PATCH] blktrace: fix for potential data overwrite

Here is the situation before the realloc:

               fd_max_size
               |
               v
   XXXOOOOXXXXX
          ^
          |
          fd_off

The X's are data, the O's are empty. What we start with after the realloc:

               fd_max_size
               |
               v
   XXXOOOOXXXXXOOOOOOOOOOOO
          ^
          |
          fd_off

In the original code we have the movement of data from byte 0
(tip->fd_buf) to tip->fd_off - over-writing data. I think if we use
tip->fd_max_size, we get the desired result (note: tip->fd_max_size is
updated to 2 times the size AFTER the memmove).
blktrace.c