[flashrom] [PATCH] CID1129996: Unchecked return value from library

Stefan Tauner stefan.tauner at alumni.tuwien.ac.at
Sat Apr 26 20:47:23 CEST 2014


On Tue, 19 Nov 2013 20:35:57 +0100
Stefan Reinauer <stefan.reinauer at coreboot.org> wrote:

> CID1129996: Unchecked return value from library
> 
> The function returns a value that indicates an error condition. If this is not
> checked, the error condition may not be handled correctly.
> In sp_opensocket: Value returned from a library function is not checked for
> errors before being used. This value may indicate an error condition. (CWE-252)
> 
> Signed-off-by: Stefan Reinauer <stefan.reinauer at coreboot.org>
> 
> Index: serprog.c
> ===================================================================
> --- serprog.c	(revision 1763)
> +++ serprog.c	(working copy)
> @@ -114,7 +114,11 @@
>  	}
>  	/* We are latency limited, and sometimes do write-write-read    *
>  	 * (write-n) - so enable TCP_NODELAY.				*/
> -	setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(int));
> +	if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(int))) {
> +		close(sock);
> +		msg_perr("Error: serprog cannot set socket options: %s\n", strerror(errno));
> +		return -1;
> +	}
>  	return sock;
>  }
>  #endif

Acked-by: Stefan Tauner <stefan.tauner at alumni.tuwien.ac.at>
and committed in r1777, thanks!
-- 
Kind regards/Mit freundlichen Grüßen, Stefan Tauner




More information about the flashrom mailing list