Reworked some buffer copy operations for security and performance.
Reworked some buffer copy operations for security and performance.

sschuberth/foo-cdartdisplay,sschuberth/foo-cdartdisplay,sschuberth/foo-cdartdisplay