]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephsqlite: fill 0s in unread portion of buffer 53102/head
authorPatrick Donnelly <pdonnell@redhat.com>
Fri, 18 Aug 2023 17:43:27 +0000 (13:43 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Wed, 23 Aug 2023 18:03:26 +0000 (14:03 -0400)
Unfortunately, this code is filling 0s at the beginning of the short-read
buffer.

Fixes: https://tracker.ceph.com/issues/62492
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
(cherry picked from commit d94684c1ee3d1436c878fe5d33ea27b2eb1144d5)

src/libcephsqlite.cc

index eafadcd8922bd7f70a796d4385c47d4b890082d6..52cfded7312c44fa8dbbd205d036edaf732d8a9c 100644 (file)
@@ -296,7 +296,7 @@ static int Read(sqlite3_file *file, void *buf, int len, sqlite_int64 off)
     auto end = ceph::coarse_mono_clock::now();
     getdata(f->vfs).logger->tinc(P_OPF_READ, end-start);
     if (rc < len) {
-      memset(buf, 0, len-rc);
+      memset((unsigned char*)buf+rc, 0, len-rc);
       return SQLITE_IOERR_SHORT_READ;
     } else {
       return SQLITE_OK;