In setsockopt, improved checks over input data