Ubaidullah bin Abu Yazid (may Allah have mercy on him) narrates from his father: Sayyiduna Umar bin Khattab (may Allah be pleased with him) called one of our elders from Banu Zuhrah, so I went with that elder to Umar (may Allah be pleased with him). Sayyiduna Umar (may Allah be pleased with him) was in the Hijr of the House. Sayyiduna Umar (may Allah be pleased with him) asked that old man about childbirth in the time of ignorance. He said: In the time of ignorance, when a woman was divorced or her husband died, she would marry again without observing any waiting period. So a man would say, "The sperm is from so-and-so, and the child was born on the bed of so-and-so." Sayyiduna Umar (may Allah be pleased with him) said: "You have spoken the truth, but the Messenger of Allah (peace and blessings be upon him) gave the ruling: The child belongs to the one on whose bed he was born."
Hadith Referenceالسنن المأثورة / باب ما جاء في فدية الأذى / 489
Hadith Takhrijسنن ابن ماجہ النکاح باب الولد للفراش وللعاهر الحجر، رقم: 2005 وقال الالبانی: صحیح ، مسند الحميدي : 15/1، رقم : 24 ، السنن الكبرى للبيهقي : 403/7۔