[PATCHSET] Fix and add -Werror=strict-overflow -Wstrict-overflow=2

jim jim.brown at rsmas.miami.edu
Thu Dec 7 20:18:54 UTC 2017


This change is wrong. Original code '(nread == 0) || ...' is more correct.
More rigorous would be (nread == 0) || (nread > 0 && namebuf[nread-1] != 
'\0').
nread is 0 resulting in invalid access to namebuf[nread-1] in while 
condition check.

On 12/7/2017 2:37 PM, Andreas Schneider via samba-technical wrote:
> diff --git a/source3/modules/vfs_preopen.c b/source3/modules/vfs_preopen.c
> index 18b01e6c05e..4ef0a2e34ab 100644
> --- a/source3/modules/vfs_preopen.c
> +++ b/source3/modules/vfs_preopen.c
> @@ -156,7 +156,7 @@ static bool preopen_helper_open_one(int sock_fd, char **pnamebuf,
>   
>   	nread = 0;
>   
> -	while ((nread == 0) || (namebuf[nread-1] != '\0')) {
> +	while (namebuf[nread-1] != '\0') {
>   		ssize_t thistime;
>   
>   		thistime = read(sock_fd, namebuf + nread,
> -- 2.15.1




More information about the samba-technical mailing list