Yes it is safe. Just make sure you keep a correct form (just as if you were using only a barbell). You can also place the safety stoppers in the position (or height) that you think is appropriate and safe for you. And never think about what others might think of you when you are working out.
Yes, you do need to be careful when performing squats with a Smith machine–and yes, you can get injured. Performing a squat with a regular barbell or free weights allows your movement pattern to follow a natural arc. The Smith machine does not allow for this natural movement. It is more fixed and unnatural, and loads the spine in a way that can set you up for injury (to your back and knees).
It is not a piece of equipment that I personally prefer for squats. That being said, if it is all you have and you are going to use it, please make sure you know how to position your feet properly.
I was never a big fan of Smith machine squats, but would be lying if I said I never did them. As the others have said, the natural arc of a free barbell squat is simply not there because a Smith machine bar travels in a fixed straight line. If memory serves me correctly, placing your feet a little further out in front as compared to a regular barbell squat should compensate for that. But you should be able to put barbell pegs on the outside of the Smith machine frame to do free-standing squats. If not, check Craigslist for a squat rack – they’re cheaper than Smith machines!