This is an example of what's called an Attachment Ambiguity.
It's very common in English, especially at the end of a sentence, for two major reasons
- English is a right-branching language, and thus tends to add qualifications at the end
- English prepositional phrases and adverbs may occur in many different locations
Together this means that a final qualification may refer
either to the constituent it's closest to,
or to some earlier constituent in the sentence.
It's ambiguous about what it's attached to.
For example, the sentence below
- She saw a cat hissing at a dog on a fence.
- She saw [a cat on a fence] hissing at a dog.
or it can mean that the dog was on the fence,
or it can mean they both were;
or it can mean that she was on the fence,
or it can mean that they all were.
In speech this is not a problem, because intonation and rhythm always distinguish the sense.
But in writing, it's important to be aware of potential attachment ambiguities,
in case you don't want to be ambiguous. Though in fact most people don't notice, or care.
That's why it's also important to be aware of them in reading, too,
because people may not be intending to be understood the way you first suspect.