A former upstate NY police officer fired for peddling drugs on the job has pleaded guilty to 40 narcotics-related charges in an Ontario County Court.