40 amp range into 50 amp plug
Using a 50A plug and receptacle is allowed on a 40A circuit because of an exception in the Electrical Code.  The exception is because 40A receptacles do not exist, or rather, are not part of the NEMA standards. (There are enough varieties of receptacle already!) 

The circuit breaker must be no larger than the wiring is fit for - if the wiring is 8 AWG, the breaker must be 40A (or smaller).   If the wire is 6 AWG, the breaker may be 40 or 50 amps (or any value up to 50A).  With large circuits like this, there is only one appliance per circuit.   I am not sure whether it is legal to plug a 40A rated appliance into a circuit breakered for 50A.  I would downgrade the breaker to 40A for an extra bit of safety. 

This is a good time to look at the receptacle.  If it's an old NEMA 10-50 type, it does not have a ground wire, and any problem with the neutral can electrify the chassis of the stove, a potentially lethal situation.  A ground wire can be retrofitted using any viable route back to the panel. (Grounds don't have to travel with the conductors).  Then you can upgrade the connectors to NEMA 14-50 type and change the jumper on the appliance to use a separate ground.