Yes, completely legal. Your contract with them is 5 nights for 150$/night. Change the nights, then they are free to charge you whatever BAR is of that day.
It's like one of those MR deals/packages of stay 5 nights and get 25% off, any nights less than that it's standard rate. You can't book 5 nights with a discount and get away with staying 4 or lesser nights for the same price per night.
Now the hotel can give you leeway, but if they go by the book then you can't complain. And no, asking front desk doesn't count. They don't have the authority.