BAYHAQI 555:
from Rasūl —
[Machine] The man complained to the Messenger of Allah ﷺ that something occurs to him during prayer. The Prophet ﷺ said, "Do not break your prayer until you hear a sound or smell an odor." Ash-Shafi'i said in the narration of Abu Sa'id, "When the Sunnah proved that the man should leave the prayer due to a smell, the smell was from the path of excrement, and there was more of it."
البيهقي ٥٥٥:
عن رسول —
شُكِيَ إِلَى رَسُولِ اللهِ ﷺ الرَّجُلُ يُخَيَّلُ إِلَيْهِ الشَّيْءُ فِي الصَّلَاةِ فَقَالَ لَا يَنْفَتِلْ حَتَّى يَسْمَعَ صَوْتًا أَوْ يَجِدَ رِيحًا قَالَ الشَّافِعِيُّ ؓ فِي رِوَايَةِ أَبِي سَعِيدٍ فَلَمَّا دَلَّتِ السُّنَّةُ عَلَى أَنَّ الرَّجُلَ يَنْصَرِفُ مِنَ الصَّلَاةِ بِالرِّيحِ كَانَتِ الرِّيحُ مِنْ سَبِيلِ الْغَائِطِ وَكَانَ الْغَائِطُ أَكْثَرَ مِنْهَا
hadithunlocked.com