The magnetic field structure in CTA 102 from high-resolution mm-VLBI observations during the flaring state in 2016–2017