[PATCH] Fix bug in proxy_write()

Antonio Borneo borneo.antonio at gmail.com
Sun Feb 9 01:50:39 EST 2014


On Sun, Feb 9, 2014 at 12:44 AM, David Woodhouse <dwmw2 at infradead.org> wrote:
> On Sat, 2014-02-08 at 23:10 +0800, Antonio Borneo wrote:
>>
>> Actually proxy_write() is used also for regular files
>> in run_csd_script():
>>         fd = mkstemp(fname);
>>         ...
>>         ret = proxy_write(vpninfo, fd, (void *)buf, buflen);
>
>
> Hm, do we actually need to use proxy_write() here? Adam did that in
> commit cc09a51eb — quite possibly at my instigation.
>
> In *theory* we should loop on write() to regular files because it can
> return having written fewer bytes than we asked. But in practice it will
> never happen, and most userspace would break if it did.
>
> Still, while it was essentially "free" to do the right thing, it made a
> certain amount of sense to be anal about it and to use proxy_write().
>
> But once we have to start jumping through hoops to make proxy_write()
> choose whether to do write() or send(), perhaps the better answer is
> just to use a simple write() in run_csd_script() to write to the file?

Agree!
Also, the issue I found is the only (ab)use of proxy_write() to write a file.
It makes sense to fix it there.

New patch in attachment.
I don't loop on write() but simply check if it writes fewer bytes than expected.

Antonio
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-fix-bug-in-run_csd_script.patch
Type: text/x-patch
Size: 1439 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/openconnect-devel/attachments/20140209/e6009e8b/attachment.bin>


More information about the openconnect-devel mailing list