First, if bad flashing is causing a leak, prevent excess water damage by covering the exposed area with a tarp or plastic. You can hold the cover in place with wood strips nailed to the roof until you are ready to fix the problem. If water is already dripping inside, redirect the stream into a bucket by nailing a small block of wood to the ceiling/attic.
Once you can access your roof, you need to replace the flashing or seal the seams with roofing cement and additional flashing. If metal flashing is corroded or rusting, it will need to be replaced. The flashing simply needs to be resealed if the flashing is still sound, but the joints are cracked or chipped.
First, remove all loose, cracked or broken material and debris before resealing the flashing. Then, re-install the flashing with appropriate adhesives. The materials needed for this type of repair depend on where the flashing is located. Mortar, roofing cement, rubber caulk and roofing tape are all possible adhesives and sealers for flashing. Choose an appropriate flashing (metal, plastic, flat, bent, molded, corrugated, etc.) when installing or replacing flashing.
The primary principle to remember when installing and repairing flashing is that you want the water to run down the roof's slope. Sometimes this means the flashing is installed under the shingles and other times this means that flashing is placed on the top of shingles. If you are unsure of the proper way to install a piece of flashing, consult a professional to ensure that your home is protected from the elements.