[prev in list] [next in list] [prev in thread] [next in thread] 

List:       flashrom
Subject:    Re: [flashrom] [PATCH] CID1129996: Unchecked return value from library
From:       Stefan Tauner <stefan.tauner () alumni ! tuwien ! ac ! at>
Date:       2014-04-26 18:47:23
Message-ID: 201404261847.s3QIlN5r030404 () mail2 ! student ! tuwien ! ac ! at
[Download RAW message or body]

On Tue, 19 Nov 2013 20:35:57 +0100
Stefan Reinauer <stefan.reinauer@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@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@alumni.tuwien.ac.at>
and committed in r1777, thanks!
-- 
Kind regards/Mit freundlichen Grüßen, Stefan Tauner

_______________________________________________
flashrom mailing list
flashrom@flashrom.org
http://www.flashrom.org/mailman/listinfo/flashrom
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic