There's really no definitive way to ensure a used gun isn't stolen, even if procured through a dealer, because all stolen guns aren't reported, either because the owner doesn't want to deal with the issue or the owner may not know the gun is no longer in his possession.

I know people who keep a gun or two in vacation cabins that they may not visit for several months; a gun stolen from one of those cabins might not be reported for quite some time.

Most states do not require that a stolen gun report be filed; if the gun hasn't much value, the owner may not want to invest the effort to report the theft. Most states also don't have any form of firearms registration.