[genius: 1/2] * src/mpwrap.c, src/lexer.l, src/compil.c: Check for errors whenn setting integer and reject the
- From: Jiri (George) Lebl <jirka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [genius: 1/2] * src/mpwrap.c, src/lexer.l, src/compil.c: Check for errors whenn setting integer and reject the
- Date: Fri, 8 Jan 2021 01:20:53 +0000 (UTC)
commit 5d0bd36a079b77b7b126255663a6e69b78b1c9d9
Author: Jiri (George) Lebl <jiri lebl gmail com>
Date: Thu Jan 7 17:20:33 2021 -0800
* src/mpwrap.c, src/lexer.l, src/compil.c: Check for errors whenn
setting integer and reject the parse.
ChangeLog | 5 +++++
src/compil.c | 5 +++++
src/lexer.l | 24 ++++++++++++++++++++++++
src/mpwrap.c | 5 ++++-
4 files changed, 38 insertions(+), 1 deletion(-)
---
diff --git a/ChangeLog b/ChangeLog
index 22b34893..8fa92a22 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Jan 07 17:20:30 2021 Jiri (George) Lebl <jirka 5z com>
+
+ * src/mpwrap.c, src/lexer.l, src/compil.c: Check for errors whenn
+ setting integer and reject the parse.
+
Wed Dec 16 13:53:33 2020 Jiri (George) Lebl <jirka 5z com>
* src/genius-readline-helper.c: fix warning by using the right list
diff --git a/src/compil.c b/src/compil.c
index 9183f386..28c6043a 100644
--- a/src/compil.c
+++ b/src/compil.c
@@ -253,6 +253,11 @@ gel_decompile_node(char **ptrptr)
if G_UNLIKELY (!p) return NULL;
mpw_init(tmp);
mpw_set_str(tmp,p,10);
+ if G_UNLIKELY (gel_error_num == GEL_NUMERICAL_MPW_ERROR) {
+ gel_errorout (_("Bad value record when decompiling"));
+ gel_error_num = GEL_NO_ERROR;
+ mpw_set_ui(tmp,0);
+ }
return gel_makenum_use(tmp);
case GEL_MATRIX_NODE:
p = strtok_r(NULL,";", ptrptr);
diff --git a/src/lexer.l b/src/lexer.l
index 477e7900..4f69a925 100644
--- a/src/lexer.l
+++ b/src/lexer.l
@@ -375,6 +375,10 @@ local { DO_RET; return LOCAL; }
[1-9][0-9]*i?[ ][1-9][0-9]*i?[/][1-9][0-9]*i? {
mpw_init(yylval.val);
mpw_set_str(yylval.val,yytext,10);
+ if G_UNLIKELY (gel_error_num == GEL_NUMERICAL_MPW_ERROR) {
+ gel_error_num = GEL_NO_ERROR;
+ REJECT;
+ }
DO_RET;
return NUMBER;
}
@@ -382,6 +386,10 @@ local { DO_RET; return LOCAL; }
[0-9]+i {
mpw_init(yylval.val);
mpw_set_str_complex_int(yylval.val,yytext,10);
+ if G_UNLIKELY (gel_error_num == GEL_NUMERICAL_MPW_ERROR) {
+ gel_error_num = GEL_NO_ERROR;
+ REJECT;
+ }
DO_RET;
return NUMBER;
}
@@ -398,6 +406,10 @@ local { DO_RET; return LOCAL; }
mpw_init(yylval.val);
mpw_set_str_complex(yylval.val,s,10);
g_free(s);
+ if G_UNLIKELY (gel_error_num == GEL_NUMERICAL_MPW_ERROR) {
+ gel_error_num = GEL_NO_ERROR;
+ REJECT;
+ }
DO_RET;
return NUMBER;
}
@@ -414,6 +426,10 @@ local { DO_RET; return LOCAL; }
mpw_init(yylval.val);
mpw_set_str_float(yylval.val,s,10);
g_free(s);
+ if G_UNLIKELY (gel_error_num == GEL_NUMERICAL_MPW_ERROR) {
+ gel_error_num = GEL_NO_ERROR;
+ REJECT;
+ }
DO_RET;
return NUMBER;
}
@@ -429,6 +445,10 @@ local { DO_RET; return LOCAL; }
mpw_init(yylval.val);
mpw_set_str_int(yylval.val,s,base);
g_free(s);
+ if G_UNLIKELY (gel_error_num == GEL_NUMERICAL_MPW_ERROR) {
+ gel_error_num = GEL_NO_ERROR;
+ REJECT;
+ }
DO_RET;
return NUMBER;
}
@@ -438,6 +458,10 @@ local { DO_RET; return LOCAL; }
[0-9]+ {
mpw_init(yylval.val);
mpw_set_str_int(yylval.val,yytext,0);
+ if G_UNLIKELY (gel_error_num == GEL_NUMERICAL_MPW_ERROR) {
+ gel_error_num = GEL_NO_ERROR;
+ REJECT;
+ }
DO_RET;
return NUMBER;
}
diff --git a/src/mpwrap.c b/src/mpwrap.c
index 7e2b1bdb..a6750929 100644
--- a/src/mpwrap.c
+++ b/src/mpwrap.c
@@ -2757,7 +2757,10 @@ mpwl_set_str_int(MpwRealNum *rop,const char *s,int base)
mpwl_clear(rop);
mpwl_init_type(rop,MPW_INTEGER);
}
- mpz_set_str(rop->data.ival,s,base);
+ if G_UNLIKELY (mpz_set_str(rop->data.ival,s,base) < 0) {
+ gel_errorout (_("Invalid integer format"));
+ gel_error_num = GEL_NUMERICAL_MPW_ERROR;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]