aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Boeing <jonathan.n.boeing@gmail.com>2015-02-09 20:01:36 -0700
committerGene Cumm <gene.cumm@gmail.com>2015-05-03 10:49:51 -0400
commit1361dd215ff3d303c8ae9e7598ef3ef91bd21d0a (patch)
tree813dc4c74ffbb0286f3d23fea912d74a7f7722f2
parentb15c5f186d2b1f55f4eacbeb35b2da99c5366dd7 (diff)
downloadsyslinux-1361dd215ff3d303c8ae9e7598ef3ef91bd21d0a.tar.gz
syslinux-1361dd215ff3d303c8ae9e7598ef3ef91bd21d0a.tar.xz
syslinux-1361dd215ff3d303c8ae9e7598ef3ef91bd21d0a.zip
gpllib: fix sizeof(char *) misuse
The code was passing sizeof(char *) - not the length of the buffer - to strlcpy and snprintf. Change the function to take the length of the buffer as a parameter. Fixes the warning: argument to 'sizeof' in 'snprintf' call is the same expression as the destination; did you mean to provide an explicit length? Signed-off-by: Jonathan Boeing <jonathan.n.boeing@gmail.com>
-rw-r--r--com32/gpllib/dmi/dmi.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/com32/gpllib/dmi/dmi.c b/com32/gpllib/dmi/dmi.c
index ef84e1e8..5a25b413 100644
--- a/com32/gpllib/dmi/dmi.c
+++ b/com32/gpllib/dmi/dmi.c
@@ -100,20 +100,20 @@ static const char *dmi_system_reset_boot_option(uint8_t code)
return out_of_spec;
}
-static void dmi_system_reset_count(uint16_t code, char *array)
+static void dmi_system_reset_count(uint16_t code, char *array, size_t len)
{
if (code == 0xFFFF)
- strlcpy(array, "Unknown", sizeof array);
+ strlcpy(array, "Unknown", len);
else
- snprintf(array, sizeof array, "%u", code);
+ snprintf(array, len, "%u", code);
}
-static void dmi_system_reset_timer(uint16_t code, char *array)
+static void dmi_system_reset_timer(uint16_t code, char *array, size_t len)
{
if (code == 0xFFFF)
- strlcpy(array, "Unknown", sizeof array);
+ strlcpy(array, "Unknown", len);
else
- snprintf(array, sizeof array, "%u min", code);
+ snprintf(array, len, "%u min", code);
}
/*
@@ -947,13 +947,17 @@ void dmi_decode(struct dmi_header *h, uint16_t ver, s_dmi * dmi)
dmi_system_reset_boot_option((data[0x04] >> 3) & 0x3),
sizeof dmi->system.system_reset.boot_option_on_limit);
dmi_system_reset_count(WORD(data + 0x05),
- dmi->system.system_reset.reset_count);
+ dmi->system.system_reset.reset_count,
+ sizeof(dmi->system.system_reset.reset_count));
dmi_system_reset_count(WORD(data + 0x07),
- dmi->system.system_reset.reset_limit);
+ dmi->system.system_reset.reset_limit,
+ sizeof(dmi->system.system_reset.reset_limit));
dmi_system_reset_timer(WORD(data + 0x09),
- dmi->system.system_reset.timer_interval);
+ dmi->system.system_reset.timer_interval,
+ sizeof(dmi->system.system_reset.timer_interval));
dmi_system_reset_timer(WORD(data + 0x0B),
- dmi->system.system_reset.timeout);
+ dmi->system.system_reset.timeout,
+ sizeof(dmi->system.system_reset.timeout));
break;
case 24: /* 3.3.25 Hardware Security */
if (h->length < 0x05)