summaryrefslogtreecommitdiff
path: root/common/options.c
diff options
context:
space:
mode:
authorThomas Markwalder <tmark@isc.org>2014-08-28 07:56:20 -0400
committerThomas Markwalder <tmark@isc.org>2014-08-28 08:12:30 -0400
commita07d99bbefd67a238b66341f84c6c63f7f35540e (patch)
tree07bb7bcc8187364b785423822ddcd8dde667319c /common/options.c
parent36e2c22493c0f2357aec2ccf4ed37c2eb676bc56 (diff)
downloadisc-dhcp-a07d99bbefd67a238b66341f84c6c63f7f35540e.tar.gz
[master] Corrects medium impact issues reported by Coverity.
Merges in rt36933
Diffstat (limited to 'common/options.c')
-rw-r--r--common/options.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/common/options.c b/common/options.c
index 374cb573..dc96d827 100644
--- a/common/options.c
+++ b/common/options.c
@@ -1849,6 +1849,15 @@ const char *pretty_print_option (option, data, len, emit_commas, emit_quotes)
* of the last format type and we add 1 to
* cover the entire first record.
*/
+
+ /* If format string had no valid entries prior to
+ * 'a' hunkinc will be 0. Ex: "a", "oa", "aA" */
+ if (hunkinc == 0) {
+ log_error ("%s: invalid 'a' format: %s",
+ option->name, option->format);
+ return ("<error>");
+ }
+
numhunk = ((len - hunksize) / hunkinc) + 1;
len_used = hunksize + ((numhunk - 1) * hunkinc);
} else {
@@ -1856,6 +1865,15 @@ const char *pretty_print_option (option, data, len, emit_commas, emit_quotes)
* It is an 'A' type array - we repeat the
* entire record
*/
+
+ /* If format string had no valid entries prior to
+ * 'A' hunksize will be 0. Ex: "A", "oA", "foA" */
+ if (hunksize == 0) {
+ log_error ("%s: invalid 'A' format: %s",
+ option->name, option->format);
+ return ("<error>");
+ }
+
numhunk = len / hunksize;
len_used = numhunk * hunksize;
}