summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Kanios <keith@kanios.net>2010-11-06 15:13:03 -0500
committerKeith Kanios <keith@kanios.net>2010-11-06 15:13:03 -0500
commite77749400675a3e858d7c88e5a14d19ed70a7403 (patch)
tree7763884f0dc4223b8436a077800c007d79b365ae
parentcae5a26057ced61f5191b9adf096c47b31f4a0e3 (diff)
downloadnasm-e77749400675a3e858d7c88e5a14d19ed70a7403.tar.gz
preproc.c: added support for REP_LIMIT
-rw-r--r--preproc.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/preproc.c b/preproc.c
index 508e09f6..6014c245 100644
--- a/preproc.c
+++ b/preproc.c
@@ -226,9 +226,9 @@ struct ExpDef {
Line *last;
int linecount; /* number of lines within expansion */
- uint32_t def_depth; /* current number of definition pairs deep */
- uint32_t cur_depth; /* current number of expansions */
- uint32_t max_depth; /* maximum number of expansions allowed */
+ int64_t def_depth; /* current number of definition pairs deep */
+ int64_t cur_depth; /* current number of expansions */
+ int64_t max_depth; /* maximum number of expansions allowed */
int state; /* condition state */
bool ignoring; /* ignoring definition lines */
@@ -333,6 +333,9 @@ enum {
*/
#define DEADMAN_LIMIT (1 << 20)
+/* max reps */
+#define REP_LIMIT ((INT64_C(1) << 62))
+
/*
* Condition codes. Note that we use c_ prefix not C_ because C_ is
* used in nasm.h for the "real" condition codes. At _this_ level,
@@ -3060,7 +3063,12 @@ issue_error:
error(ERR_NONFATAL, "non-constant value given to `%%rep'");
return DIRECTIVE_FOUND;
}
- count = reloc_value(evalresult) + 1;
+ count = reloc_value(evalresult);
+ if (count >= REP_LIMIT) {
+ error(ERR_NONFATAL, "`%%rep' value exceeds limit");
+ count = 0;
+ } else
+ count++;
} else {
error(ERR_NONFATAL, "`%%rep' expects a repeat count");
count = 0;