this could be for a number of reasons.. though it'd've helped to know if other browsers are able to connect to yahoo or google
anyway, it could be that someone has fiddled with your hosts file and blocked out those site.. some viruses are known to rewrite the hosts file to block online antivirus scanners but i've never heard of any virus that blocks yahoo or google.. another reason could be if you're connecting through a proxy, if you've recently installed a firewall..this can also block certain sites.. and if you're connecting through a local network, like in work or at campus then the administrator might have blocked out those sites.
first check your hosts file
for windows xp and above browse to this path on your computer:
C:\WINDOWS\SYSTEM32\DRIVERS\etc
for windows 9x/me look for hosts there:
c:\windows
look for a file called hosts open it with notepad.exe and do a find text for google or yahoo entries...if you do then remove the lines containing google/yahoo
if the hosts file is ok, then try to see if you're using a proxy, open your firefox settings and click the connection settings button, see if a proxy server is configured..if so..remove it and make firefox connect directly using your broadband or dialup connection...
if no proxy is configured, then check in your firewall settings..look for something called blocked sites/domains etc.
if you're using a local network, then check with the administrator to see if he has deliberately blocked those sites
if all those solutions don't apply to you then finally contact your isp and explain the problem..maybe someone there blocked those sites by mistake(believe it or not..sometimes those tech guys as isp companies do weird things probably by mistake..and once i had to go for a couple of days without the bbc news site because someone at my isp blocked it ..and they didn't even know till i've called them).
and finally..do a virus scan..it'dn't harm..update your antivirus defintions and do a thorough scan.
hope you'll be able to resolve your problem soon.