You may not have much choice other than to cut open the ceiling below, or tear up the floor in that room to render a proper repair. If that pipe ever got clogged, guess what, it wouldn't only be gasses that could escape, but sewage all over the ceiling of the room below. Plus, if the wood stays damp long enough, it will rot it out and could attract carpenter ants and termites. You either need to replace the entire lead toilet bend, or cut it out and transition to plastic. If you get a new lead toilet bend, it would be long enough to come above the toilet flange and be bent over it so there'd be a continuous surface that the wax ring can seal to.