During "conflicts" eg Gulf War, there is normally an AIP issued to prohbit or advise against such terrirotial overflying. Yes,diverts/alternates need consideration but generally the high level/high alt flights overflying are safe.
On cargo/freighter flights the "nature of the cargo" or registry/tail of the aircraft will not permit over flying (potentially) hostile territory.