Another good reason for hiking poles.... as I would have used them as daggers.
I'm a dog owner (yellow lab), but rarely take her hiking b/c of a bad knee. She's leashed when I do take her out.
Usually when I'm in the scenario that the OP described, I keep hiking straight toward the dog, as if the yapping startled dog is a pest to be ignored, which usually sends the barking dog back towards it's owner. I've never had a dog continue aggressively toward me. If that happened, I would prepare my stance for quick action,,, constant jabbing motion w/ my poles, and swift kicking. I hope that would do the trick until the idiot owner could control his dog.