krb5 commit: Fix bttest printing of unterminated strings
Tom Yu
tlyu at mit.edu
Tue Aug 16 21:46:14 EDT 2016
https://github.com/krb5/krb5/commit/503b912fa11db372db043a8b8fbce51e75b36eed
commit 503b912fa11db372db043a8b8fbce51e75b36eed
Author: Tom Yu <tlyu at mit.edu>
Date: Mon Aug 8 09:12:53 2016 -0400
Fix bttest printing of unterminated strings
The libdb2 btree debugging program bttest can attempt to print keys or
data that aren't null-terminated, reading past the end of the
length-counted byte array. Use the "%.*s" format specifier to provide
an explicit length when printing keys or data.
ticket: 8478
src/plugins/kdb/db2/libdb2/test/btree.tests/main.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/plugins/kdb/db2/libdb2/test/btree.tests/main.c b/src/plugins/kdb/db2/libdb2/test/btree.tests/main.c
index 2aee3a3..78195d6 100644
--- a/src/plugins/kdb/db2/libdb2/test/btree.tests/main.c
+++ b/src/plugins/kdb/db2/libdb2/test/btree.tests/main.c
@@ -636,7 +636,7 @@ list(db, argv)
}
status = (*db->seq)(db, &key, &data, R_FIRST);
while (status == RET_SUCCESS) {
- (void)fprintf(fp, "%s\n", key.data);
+ (void)fprintf(fp, "%.*s\n", (int)key.size, key.data);
status = (*db->seq)(db, &key, &data, R_NEXT);
}
(void)fclose(fp);
@@ -661,7 +661,7 @@ rlist(db, argv)
}
status = bt_rseq(db, &key, &data, &cookie, R_FIRST);
while (status == RET_SUCCESS) {
- (void)fprintf(fp, "%s\n", key.data);
+ (void)fprintf(fp, "%.*s\n", (int)key.size, key.data);
status = bt_rseq(db, &key, &data, &cookie, R_NEXT);
}
(void)fclose(fp);
@@ -822,9 +822,9 @@ keydata(key, data)
DBT *key, *data;
{
if (!recno && key->size > 0)
- (void)printf("%s/", key->data);
+ (void)printf("%.*s/", (int)key->size, key->data);
if (data->size > 0)
- (void)printf("%s", data->data);
+ (void)printf("%.*s", (int)data->size, data->data);
(void)printf("\n");
}
More information about the cvs-krb5
mailing list