<div dir="ltr"><div>>This cannot be the right fix:</div><div>>if umove returned an error, ifc.ifc_buf is undefined.</div><div><br></div><div>Yes, I make the same mistake. How to fix this bug? Thanks.</div><div><br></div><div>--</div><div>JingPiao Chen</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-12-23 7:03 GMT+08:00 Dmitry V. Levin <span dir="ltr"><<a href="mailto:ldv@altlinux.org" target="_blank">ldv@altlinux.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Mon, Dec 19, 2016 at 11:33:46PM +0800, JingPiao Chen wrote:<br>
> sock.c: 150<br>
><br>
> 150 if (syserror(tcp) || umove(tcp, addr, &ifc) < 0) {<br>
> 151 if (ifc.ifc_buf)<br>
> 152 tprints("}");<br>
> 153 else<br>
> 154 printaddr(addr);<br>
> 155 return RVAL_DECODED | 1;<br>
> 156 }<br>
><br>
> Second enter function decode_ifconf(), if syserror(tcp) is true,<br>
> variable ifc is garbage value. "if (ifc.ifc_buf)" may be wrong.<br>
<br>
</span>Congratulations, you've found a bug. :)<br>
<span class=""><br>
> From 5b2d4f12d61e5a03212de948508e83<wbr>0c9aeeef87 Mon Sep 17 00:00:00 2001<br>
> From: JingPiao Chen <<a href="mailto:chenjingpiao@gmail.com">chenjingpiao@gmail.com</a>><br>
> Date: Mon, 19 Dec 2016 23:08:09 +0800<br>
> Subject: [PATCH 1/2] sock: fix bitwise OR operation short circuit<br>
><br>
> * sock.c (decode_ifconf): Exchange the place of syserror() and umove().<br>
> ---<br>
> sock.c | 2 +-<br>
> 1 file changed, 1 insertion(+), 1 deletion(-)<br>
><br>
> diff --git a/sock.c b/sock.c<br>
> index cf13896..0bdb7a9 100644<br>
> --- a/sock.c<br>
> +++ b/sock.c<br>
> @@ -147,7 +147,7 @@ decode_ifconf(struct tcb *tcp, const long addr)<br>
> return 1;<br>
> }<br>
><br>
> - if (syserror(tcp) || umove(tcp, addr, &ifc) < 0) {<br>
> + if (umove(tcp, addr, &ifc) < 0 || syserror(tcp)) {<br>
> if (ifc.ifc_buf)<br>
> tprints("}");<br>
<br>
</span>This cannot be the right fix:<br>
if umove returned an error, ifc.ifc_buf is undefined.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
ldv<br>
</font></span><br>------------------------------<wbr>------------------------------<wbr>------------------<br>
Developer Access Program for Intel Xeon Phi Processors<br>
Access to Intel Xeon Phi processor-based developer platforms.<br>
With one year of Intel Parallel Studio XE.<br>
Training and support from Colfax.<br>
Order your platform today.<a href="http://sdm.link/intel" rel="noreferrer" target="_blank">http://sdm.link/intel</a><br>______________________________<wbr>_________________<br>
Strace-devel mailing list<br>
<a href="mailto:Strace-devel@lists.sourceforge.net">Strace-devel@lists.<wbr>sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/strace-devel" rel="noreferrer" target="_blank">https://lists.sourceforge.net/<wbr>lists/listinfo/strace-devel</a><br>
<br></blockquote></div><br></div>