Thread (23 messages) 23 messages, 3 authors, 2017-04-20

Re: [PATCH v5 3/8] convert: Split start_multi_file_filter into two separate functions

flat view

From: Lars Schneider <hidden>
Date: 2017-04-11 20:01:11

On 11 Apr 2017, at 21:37, Jeff King [off-list ref] wrote:

On Tue, Apr 11, 2017 at 09:29:36PM +0200, Lars Schneider wrote:
quoted
quoted
1. Do we need to save errno before calling sigchain_pop()? It's making
   syscalls (though admittedly they are unlikely to fail).
What if we add the following right before sigchain_pop() ?

	if (errno == EPIPE)
		err = -1;
Yes, that would be fine (though again, this runs against point 2 below).
quoted
quoted
2. If err is 0, then nothing failed. Who would have set errno? Aren't
   we reading whatever cruft happened to be in errno before the
   function started?
Yeah, looks like you're right:
https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=6619179

According to this article we shouldn't even check *only* for errno. 
At least we should add
	errno = 0;
at the beginning of the function, no?
If you initialize errno to 0 right before a syscall, then yes, you can
trust it without checking the return value of the syscall. I wouldn't
trust it before calling more complicated functions, though. Not even
xwrite(), which may see EINTR and keep going (which is OK for checking
for EPIPE, but not checking generally for errno values).
Should we remove all the errno checks here as we don't have any direct 
"write" etc syscalls anyways then?


- Lars
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help