Regularity results for sub-Riemannian geodesics