Question 11a on Form 4473 is "Are you the actual transferee/buyer of the firearm(s) listed on this form?"
If you're buying a firearm for yourself with the full intent to give as a gift, then you are the actual buyer. If you're buying it for your unprohibited friend who is 100% legal to own the firearm, but he's just too busy to go to the gun store and he gave you the money, it is an illegal straw purchase.
If you buy a firearm with the express purpose of immediately reselling it to an otherwise legal person, then it is still a straw purchase.
If you buy a firearm and decide you don't like it, then sell it to that legal person with a clean record, then that is legal.
ETA: I took this from a post on ARFCOM.