The legal standard for police to conduct a traffic stop is whether there is reasonable suspicion that criminal activity has happened or is happening. A violatioin of a traffic offense is enough for a police officer to conduct a traffic stop and detain the occupants to conduct an investigation into the suspected crimimal activity. Probable cause, consent, or a warrant is necessary to conduct a search of the vehicle. However, the officer may "pat down" a citizen for safety to determine whether he/she is armed. Police cannot automatically search a citizen who is not under arrest and where there is no reason to believe he/she is armed. The police may search a person incident to a lawful arrest. If the police searched your back pack without probable cause or a warrant, you have may have a good defense.
On the facts you described:
Expired safety sticker is grounds for a stop.
The stop is grounds for the search.
The evidence recovered is grounds for charges.
If you have been charged, contact a criminal defense attorney immediately.
READ THIS BEFORE CALLING OR EMAILING ME: I am licensed to practice before the state and federal courts in Virginia. We have not established an attorney-client relationship unless we have a signed representation agreement and you have paid me. I give a 100% effort to get you on the right track with your issue. Sometimes that means legal educational information, sometimes that means counseling and non-legal guidance. You should speak with an attorney to whom you have provided all the facts, before you take steps that may impact your legal rights. I am not obligated to answer subsequent emails or phone calls unless you have hired me. I wish you the best of luck with your situation.