Skip to contentSkip to conversation

nfsdcld: fix possible buffer overrun in sqlite_iterate_recovery()

PATCH In review Scott Mayhew 2 participants 2 messages Apr 13, 2020 – Apr 14, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfsdcld: fix possible buffer overrun in sqlite_iterate_recovery()

Prior to release, cp_data was originally intended to hold the gss principal string. When it was changed to hold a hash of the principal instead, the size of the field was changed but the 'n' arg of the memcpy() in sqlite_iterate_recovery() was not.

---
 utils/nfsdcld/sqlite.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/nfsdcld/sqlite.c +1 -1
index 09518e2..6666c86 100644
@@ -1337,7 +1337,7 @@ sqlite_iterate_recovery(int (*cb)(struct cld_client *clnt), struct cld_client *c
 		cmsg->cm_u.cm_clntinfo.cc_name.cn_len = sqlite3_column_bytes(stmt, 0);
 		if (sqlite3_column_bytes(stmt, 1) > 0) {
 			memcpy(&cmsg->cm_u.cm_clntinfo.cc_princhash.cp_data,
-				sqlite3_column_blob(stmt, 1), NFS4_OPAQUE_LIMIT);
+				sqlite3_column_blob(stmt, 1), SHA256_DIGEST_SIZE);
 			cmsg->cm_u.cm_clntinfo.cc_princhash.cp_len = sqlite3_column_bytes(stmt, 1);
 		}
 #else
Signature · 1 line
2.25.1
#1 lore raw
Quoted 6 lines · Scott Mayhew

Prior to release, cp_data was originally intended to hold the gss principal string. When it was changed to hold a hash of the principal instead, the size of the field was changed but the 'n' arg of the memcpy() in sqlite_iterate_recovery() was not.

Committed... (tag: nfs-utils-2-4-4-rc3)

steved.

Quoted 18 lines
---
 utils/nfsdcld/sqlite.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/nfsdcld/sqlite.c +1 -1
index 09518e2..6666c86 100644
@@ -1337,7 +1337,7 @@ sqlite_iterate_recovery(int (*cb)(struct cld_client *clnt), struct cld_client *c
 		cmsg->cm_u.cm_clntinfo.cc_name.cn_len = sqlite3_column_bytes(stmt, 0);
 		if (sqlite3_column_bytes(stmt, 1) > 0) {
 			memcpy(&cmsg->cm_u.cm_clntinfo.cc_princhash.cp_data,
-				sqlite3_column_blob(stmt, 1), NFS4_OPAQUE_LIMIT);
+				sqlite3_column_blob(stmt, 1), SHA256_DIGEST_SIZE);
 			cmsg->cm_u.cm_clntinfo.cc_princhash.cp_len = sqlite3_column_bytes(stmt, 1);
 		}
 #else