birdgirl hit it...probable cause. Because you were caught in the commision of a crime, they had enough reason to warrant a search without a warrant. If I remember correctly (someone keep me honest) this was played out years ago in the Supreme Court. A guy questioned the searching of his car without a warrant and in which drugs were found. The courts basically said that 'probable cause' trumps the need for getting a warrant, particuarly when the subject of the warrant (ie. car) can be moved.

Now, let's say you and your friends had just got done smoking and the same situation would have happened. Well, now you can question their authority to do a search. However, they can also waste 2 hours of your life by requesting a drug dog to do an outside search would would warrant a search of the inside if the dog makes a 'hit'. Your damned if you do and your damned if you don't.