diff --git a/src/finfield.c b/src/finfield.c index 8578622196..d7a35ea0d2 100644 --- a/src/finfield.c +++ b/src/finfield.c @@ -544,6 +544,8 @@ FF FiniteField ( } if (ff < 1 || ff > NUM_SHORT_FINITE_FIELDS) return 0; + if (CharFF[ff] != p) + return 0; if (SizeFF[ff] != q) return 0; #ifdef HPCGAP @@ -1700,7 +1702,6 @@ Obj FuncIS_FFE ( ** with respect to the root which must lie in the same field like . */ Obj LOG_FFE_LARGE; -#include Obj FuncLOG_FFE_DEFAULT ( Obj self, diff --git a/tst/testbugfix/2017-08-07-FFE-bad-char.tst b/tst/testbugfix/2017-08-07-FFE-bad-char.tst new file mode 100644 index 0000000000..fc3b03da75 --- /dev/null +++ b/tst/testbugfix/2017-08-07-FFE-bad-char.tst @@ -0,0 +1,13 @@ +# Invoking Z(p,d) with p not a prime used to crash gap, which we fixed. +# However, invocations like `Z(4,5)` still would erroneously trigger the +# creation of a type object for fields of size p^d (in the example: 1024), +# with the non-prime value p set as characteristic. This could then corrupt +# subsequent computations. +gap> Z(4,5); +Error, Z:

must be a prime +gap> FieldByGenerators(GF(2), [ Z(1024) ]); +GF(2^10) +gap> Characteristic(Z(1024)); +2 +gap> Characteristic(FamilyObj(Z(1024))); +2