|
From: Joseph C. <jos...@in...> - 2010-07-17 01:23:23
|
changeset 11a17c26aafb in /var/www/tboot.hg
details: tboot.hg?cmd=changeset;node=11a17c26aafb
description:
Fixed buffer overrun errors in lcptools/ and compilation error on some systems in utils/
In lcptools/, crtpol and crtpolelt had buffer overrun bugs that are now fixed.
parse_err.c and txt-stat.c assumed that sys/user.h and/or sys/mman.h would provide the definition of PAGE_SHIFT and PAGE_SIZE. However, this is not the case on all systems. Moreover, the tboot files that use these assume that they are 4k pages. This change defines this explicitly to be 4k.
The error in crtpolelt.c was discovered by Martin Pirker. The others were reported by Michael Gissing. Fixes for all were provided by Michael Gissing.
Signed-off-by: Michael Gissing <m.g...@tu...>
Signed-off-by: Joseph Cihula <jos...@in...>
diffstat:
lcptools/crtpol.c | 4 ++--
lcptools/crtpolelt.c | 4 ++--
utils/parse_err.c | 10 ++++++++++
utils/txt-stat.c | 12 +++++++++++-
4 files changed, 25 insertions(+), 5 deletions(-)
diffs (88 lines):
diff -r d213448f6261 -r 11a17c26aafb lcptools/crtpol.c
--- a/lcptools/crtpol.c Thu Jul 15 23:30:42 2010 -0700
+++ b/lcptools/crtpol.c Fri Jul 16 16:05:51 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001 - 2009 Intel Corporation. All Rights Reserved.
+ * Copyright 2001 - 2010 Intel Corporation. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -462,7 +462,7 @@
goto _error_end;
}
/* ensure that convert_hashes() won't overrun the buffer */
- mle_data_ascii[BUFFER_SIZE] = '\0';
+ mle_data_ascii[BUFFER_SIZE - 1] = '\0';
/* convert ASCII hashes to binary */
if ( convert_hashes(mle_len_ascii, mle_data_ascii, &mle_len,
mle_data) < 0 ) {
diff -r d213448f6261 -r 11a17c26aafb lcptools/crtpolelt.c
--- a/lcptools/crtpolelt.c Thu Jul 15 23:30:42 2010 -0700
+++ b/lcptools/crtpolelt.c Fri Jul 16 16:05:51 2010 -0700
@@ -1,7 +1,7 @@
/*
* crtpolelt.c: Intel(R) TXT policy element (LCP_POLICY_ELEMENT) creation tool
*
- * Copyright (c) 2009, Intel Corporation
+ * Copyright (c) 2009 - 2010, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -115,7 +115,7 @@
ERROR("Error: too many plugin options\n");
/* copy help text */
- strncat(help, plugin->help_txt, MAX_HELP_TEXT);
+ strncat(help, plugin->help_txt, MAX_HELP_TEXT - strlen(help) - 1);
}
}
diff -r d213448f6261 -r 11a17c26aafb utils/parse_err.c
--- a/utils/parse_err.c Thu Jul 15 23:30:42 2010 -0700
+++ b/utils/parse_err.c Fri Jul 16 16:05:51 2010 -0700
@@ -44,6 +44,16 @@
#include <sys/mman.h>
#include <fcntl.h>
+/* tboot code assumes 4k pages */
+#ifdef PAGE_SHIFT
+#undef PAGE_SHIFT
+#endif
+#define PAGE_SHIFT 12
+#ifdef PAGE_SIZE
+#undef PAGE_SIZE
+#endif
+#define PAGE_SIZE (1 << PAGE_SHIFT)
+
#define printk printf
#include "../tboot/include/txt/config_regs.h"
#include "../tboot/include/txt/errorcode.h"
diff -r d213448f6261 -r 11a17c26aafb utils/txt-stat.c
--- a/utils/txt-stat.c Thu Jul 15 23:30:42 2010 -0700
+++ b/utils/txt-stat.c Fri Jul 16 16:05:51 2010 -0700
@@ -45,13 +45,23 @@
#include <sys/mman.h>
#include <sys/types.h>
#include <fcntl.h>
+
+/* tboot code assumes 4k pages */
+#ifdef PAGE_SHIFT
+#undef PAGE_SHIFT
+#endif
+#define PAGE_SHIFT 12
+#ifdef PAGE_SIZE
+#undef PAGE_SIZE
+#endif
+#define PAGE_SIZE (1 << PAGE_SHIFT)
+
#define printk printf
#include "../include/config.h"
#include "../include/uuid.h"
#include "../include/tboot.h"
#include "../tboot/include/txt/config_regs.h"
-//#include "../tboot/include/txt/heap.h"
/*
* BIOS structure
*/
|