According to ICAO Air Law, a states territory extends to 12 miles from the coast, outside that are high seas and come under international law. Therefore whenever you are inside the 12 mile limit or within the FIR boundary then you are over the territory of the state and they are responsible for the safety and security of the aircraft. Also you must abide by the laws of the state.
The laws of freedom allow overflight, however, these need to be approved either as a scheduled service or individual permission for non-scheduled services.