diff options
author | Karel Zak | 2017-09-18 10:41:20 +0200 |
---|---|---|
committer | Karel Zak | 2017-09-18 10:41:20 +0200 |
commit | 7928a926a05855c3f13f3d1c115f5a3a093d57ec (patch) | |
tree | f903cb90f7a3315d526af2fc7d24a827ebce0896 /libsmartcols | |
parent | Merge branch 'patch-1' of https://github.com/aner-perez/util-linux (diff) | |
download | kernel-qcow2-util-linux-7928a926a05855c3f13f3d1c115f5a3a093d57ec.tar.gz kernel-qcow2-util-linux-7928a926a05855c3f13f3d1c115f5a3a093d57ec.tar.xz kernel-qcow2-util-linux-7928a926a05855c3f13f3d1c115f5a3a093d57ec.zip |
libsmartcols: fix scols_line_move_cells() n+1 error [asan]
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libsmartcols')
-rw-r--r-- | libsmartcols/src/line.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libsmartcols/src/line.c b/libsmartcols/src/line.c index c2a991c2d..6c64e7f62 100644 --- a/libsmartcols/src/line.c +++ b/libsmartcols/src/line.c @@ -163,12 +163,12 @@ int scols_line_move_cells(struct libscols_line *ln, size_t newn, size_t oldn) /* remove old possition (move data behind oldn to oldn) */ if (oldn + 1 < ln->ncells) memmove(ln->cells + oldn, ln->cells + oldn + 1, - (ln->ncells - oldn) * sizeof(struct libscols_cell)); + (ln->ncells - oldn - 1) * sizeof(struct libscols_cell)); /* create a space for new position */ if (newn + 1 < ln->ncells) memmove(ln->cells + newn + 1, ln->cells + newn, - (ln->ncells - newn) * sizeof(struct libscols_cell)); + (ln->ncells - newn - 1) * sizeof(struct libscols_cell)); /* copy original data to new position */ memcpy(&ln->cells[newn], &ce, sizeof(struct libscols_cell)); |