summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2010-07-22 18:17:51 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2010-07-22 18:17:51 +0200
commitdc32316be13f1f5b63d46a01812aa157a13c12e8 (patch)
treef97b4038a8ee775d71f2d1029cfaf9ef7311c191
parente6faf33067042dda86c103014f3ce99b234c3daf (diff)
downloadconnman-dc32316be13f1f5b63d46a01812aa157a13c12e8.tar.gz
connman-dc32316be13f1f5b63d46a01812aa157a13c12e8.tar.bz2
connman-dc32316be13f1f5b63d46a01812aa157a13c12e8.zip
Fix floating point error for unhandled dhcp options
Unhandled dhcp options will trigger a divide by zero exception.
-rw-r--r--gdhcp/client.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gdhcp/client.c b/gdhcp/client.c
index 21b27456..7be3d3d7 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -829,9 +829,13 @@ static char *malloc_option_value_string(uint8_t *option, GDHCPOptionType type)
len = option[OPT_LEN - OPT_DATA];
type &= OPTION_TYPE_MASK;
optlen = dhcp_option_lengths[type];
+ if (optlen == 0)
+ return NULL;
upper_length = len_of_option_as_string[type] *
((unsigned)len / (unsigned)optlen);
dest = ret = malloc(upper_length + 1);
+ if (ret == NULL)
+ return NULL;
while (len >= optlen) {
switch (type) {
@@ -908,6 +912,9 @@ static void get_request(GDHCPClient *dhcp_client, struct dhcp_packet *packet)
type = dhcp_get_code_type(code);
option_value = malloc_option_value_string(option, type);
+ if (option_value == NULL)
+ g_hash_table_remove(dhcp_client->code_value_hash,
+ GINT_TO_POINTER((int) code));
value_list = get_option_value_list(option_value);