Make crossystem.h more polite and more useful.
This adds a VB_MAX_STRING_PROPERTY for callers that don't
want to guess at how big to make their buffers.
Additionally, it changes the size parameter to VbGetPropertyString()
from int to size_t.
BUG=None
TEST=compile the code
BRANCH=none
Change-Id: I22809d48e13b535593cb22a56444e2dcb27791a5
Reviewed-on: https://chromium-review.googlesource.com/175039
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Richard Barnette <jrbarnette@chromium.org>
diff --git a/utility/crossystem.c b/utility/crossystem.c
index d7007ee..520f7fd 100644
--- a/utility/crossystem.c
+++ b/utility/crossystem.c
@@ -11,9 +11,6 @@
#include "crossystem.h"
-/* Max length of a string parameter */
-#define MAX_STRING 8192
-
/*
* Call arch specific init, if provided, otherwise use the 'weak' stub.
*/
@@ -153,7 +150,7 @@
* Returns 0 if success (match), non-zero if error (mismatch). */
int CheckParam(const Param* p, char* expect) {
if (p->flags & IS_STRING) {
- char buf[MAX_STRING];
+ char buf[VB_MAX_STRING_PROPERTY];
const char* v = VbGetSystemPropertyString(p->name, buf, sizeof(buf));
if (!v || 0 != strcmp(v, expect))
return 1;
@@ -175,7 +172,7 @@
* Returns 0 if success, non-zero if error. */
int PrintParam(const Param* p) {
if (p->flags & IS_STRING) {
- char buf[MAX_STRING];
+ char buf[VB_MAX_STRING_PROPERTY];
const char* v = VbGetSystemPropertyString(p->name, buf, sizeof(buf));
if (!v)
return 1;
@@ -197,7 +194,7 @@
int PrintAllParams(int force_all) {
const Param* p;
int retval = 0;
- char buf[MAX_STRING];
+ char buf[VB_MAX_STRING_PROPERTY];
const char* value;
for (p = sys_param_list; p->name; p++) {