Their liability is EXTREMELY limited. There is a lot of case law around this, all the way up to the supreme court. According to a 1988 Supreme Court Ruling (California vs. Greenwood), when a person throws something out, that item is now the public domain.
Only when the receptacle is on public property. Stores usually are in private leased property.
In other words, the second it hits the dumpster it's not the store's property anymore it's public domain. So they aren't responsible for food poisoning.
With that stated, trespassing laws do apply while the dumpster is on their property. Trespassing in a publicly accessible space does come with it's own set of laws. Walking into a partking lot that's open to the public is almost certainly not trespassing until you are specifically asked to leave.
Dumpster diving liability questions are so common, that the synopsis below is from a personal injury lawyer's website.
LIABILITY ISSUES ARISING FROM DUMPSTER DIVING
While many business owners are concerned that they can be held responsible if expired food or similar goods in their trash cause harm to a dumpster diver or if a dumpster diver is injured on their property, this is not usually the case.
So risk a possible lawsuit on "usually?"
Unless the business has been negligent, they should not be responsible for a dumpster diver’s injuries or illness as a result of eating or using items that have been thrown away. - Source