From b81ab32a35147a06710a58f32283d12b08599ea7 Mon Sep 17 00:00:00 2001 From: kremlin Date: Thu, 7 Aug 2014 00:10:15 -0500 Subject: [PATCH] minor, add generous fixed buffer for sysctl strings --- src/interfaces/hostnamed/hostnamed.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/interfaces/hostnamed/hostnamed.c b/src/interfaces/hostnamed/hostnamed.c index fae193e..f1c3fb4 100644 --- a/src/interfaces/hostnamed/hostnamed.c +++ b/src/interfaces/hostnamed/hostnamed.c @@ -399,16 +399,22 @@ int main() { gboolean determine_chassis_and_icon() { + const size_t bufsize = 4096; + char *hwproduct, *hwmodel, *hwvendor, *hwmachine; size_t hwproduct_size, hwmodel_size, hwvendor_size, hwmachine_size; int hwproduct_name[2], hwmodel_name[2], hwvendor_name[2], hwmachine_name[2]; unsigned int i; gboolean UNSURE_CHASSIS_FLAG, UNSURE_ICON_FLAG; - hwproduct = hwmodel = hwvendor = hwmachine = NULL; - hwproduct_size = hwmodel_size = hwvendor_size = hwmachine_size = 0; + hwproduct_size = hwmodel_size = hwvendor_size = hwmachine_size = bufsize; UNSURE_CHASSIS_FLAG = UNSURE_ICON_FLAG = FALSE; + hwproduct = (char*)g_malloc0(4096); + hwmodel = (char*)g_malloc0(4096); + hwvendor = (char*)g_malloc0(4096); + hwmachine = (char*)g_malloc0(4096); + hwproduct_name[0] = CTL_HW; hwproduct_name[1] = HW_PRODUCT; -- 2.41.0