The short answer is, in absence of a treaty or convention governing travel, then the law of the country over which the plane is located governs for the time the plane is in overflight. Laws of a jurisdiction (a country, or a state) are generally taken to extend upward from their boundaries (and downward for the control of mineral rights, etc.).
There are a number of jurisdictional cases where service of process (presenting a defendant with a copy of citation starting a civil suit) or an arrest has taken place on-board aircraft where the action had to take place over a given country or state to invoke jurisdiction.
As mentioned in the first sentence, there is nothing to prevent countries for entering into a Treaty or agreement that would alter the basic scheme, but absent a treaty or convention, the basic scheme of boundary extension would apply.