If you’re modifying existing code, what you are creating is most likely a derivative work, which requires the copyright holder’s permission. Basically, you have to rewrite the whole thing from scratch without referring to the original code to avoid a copyright violation. Anything else makes it a derivative work. And it’s unlikely that any of the fair use exceptions to copyright would be relevant. Your client needs to consult with a good copyright lawyer. And if you take on this job, you need to consult with a good copyright lawyer too.