Resilient estimation and safe control for cyber-physical systems