Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent Z(p,d), p non-prime, from breaking the type system #1573

Merged
merged 1 commit into from
Aug 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/finfield.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1700,7 +1702,6 @@ Obj FuncIS_FFE (
** with respect to the root <r> which must lie in the same field like <z>.
*/
Obj LOG_FFE_LARGE;
#include <stdio.h>

Obj FuncLOG_FFE_DEFAULT (
Obj self,
Expand Down
13 changes: 13 additions & 0 deletions tst/testbugfix/2017-08-07-FFE-bad-char.tst
Original file line number Diff line number Diff line change
@@ -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: <p> must be a prime
gap> FieldByGenerators(GF(2), [ Z(1024) ]);
GF(2^10)
gap> Characteristic(Z(1024));
2
gap> Characteristic(FamilyObj(Z(1024)));
2