The length of a horizontal line drawn from the top of the opening of the chimney flue to the point at which that line touches the roof surface should be ten feet or more. This height requirement is to assure that the chimney will develop adequate draft. A "too short" chimney won't have a tall-enough column of rising hot gases inside to develop a safe, adequate draft.
A chimney that is too short is unlikely to vent properly and it may also be a serious fire hazard to the building. Particularly with gas fired appliances, the lack of adequate draft for any reason, including a chimney flue that is too short, can result in improper combustion and the production of dangerous, potentially fatal carbon monoxide gases. And the same inadequate draft that affects combustion in the heater can increase the risk that the gas backdrafts out into the buildings.
NFPA 211 1.7.1 specifies:
... A chimney or vent shall be designed and constructed to develop a flow sufficient to completely remove all flue or vent gases to the outside atmosphere. The venting system shall satisfy the draft requirements of the connected appliance(s) in accordance with the equipment manufacturer's instructions or the chapter on Chimney, Gas Vent, and Fireplace Systems of the Equipment Volume of the ASHRAE Handbook.
An obvious fix for a chimney that is too short to meet the fire safety clearances mentioned earlier is that must be extended above the roof for fire safety.In some cases it is permitted (NFPA 211 1-7-2.) to use a draft inducer fan ("a mechanical draft system of either forced or induced draft design") to meet the draft requirements.
There is a lot of good information on the web about this topic. However, be aware that your local jurisdiction may have precedence over national code. Before making repairs be sure to consult you local municipality. When buying a home, get it inspected!