If a Muslim misses Fajr prayer and wakes up at sunrise or shortly after or before sunrise, he has to make up for Fajr when he wakes up, even if the sun rises while he is praying, or he starts praying while it rises or he starts praying after it rises and he finishes before the sun becomes white. The same ruling applies to Asr prayer, if the person overslept or forgot it, then he should pray it when he wakes up or when he remembers even if the sun sets while he is praying. He can also starts praying during the sunset, of course he should do that after he performs ablution.
He should not wait till the sun rises and becomes white to pray Fajr, and he should not wait till the sun completely sets then pray Asr, this is based on the hadith by the Prophet, Peace Be upon Him, who said: It was narrated from Abu Hurairah that the Messenger of Allah (Peace Be upon Him) said:
"Whoever catches up with a Rak'ah of the Subh prayer before the sun rises, then he has caught up with Subh, and whoever catches up with a Rak'ah of 'Asr prayer before the sun sets, then he has caught up with 'Asr." Sahih al-Bukhari (579), Sahih Muslim (608)
This is also evident in the hadith by the Prophet (PBUH): "He who forgets the prayer, or he slept (and it was omitted), its expiation is (only) that he should observe it when he remembers it." (Sahih Muslim: 684)
As for the hadith in which the Prophet (Peace Be upon Him) said: "…but when the sun rises, refrain from prayer for it rises between the horns of the devil," the scholars confirm that the command not to pray at those times is with regard to the Nawafel, i.e. not obligatory prayers or missed prayers, which the Muslim may have overslept and missed their times.
Review: Fatawa al-Lajnah al-Da'imah (Permanent Committee for Scholarly Research and Ifta) (6/14:15)