Introduction
Introduction Statistics Contact Development Disclaimer Help
Avoid zero-length iowrite - sacc - sacc - sacc(omys), simple console gopher cli…
git clone git://git.codemadness.org/sacc
Log
Files
Refs
LICENSE
---
commit 20a51bafd3906aa0337fe221d0981293d94370a5
parent 21d46d603a3697f04072e4c0edb0076b4a215a2e
Author: Michael Forney <[email protected]>
Date: Tue, 19 Mar 2024 14:52:09 -0700
Avoid zero-length iowrite
iowrite with bs==0 results in either a zero-length write() or
tls_write().
The former is unspecified by POSIX[0]:
> If nbyte is zero and the file is not a regular file, the results
> are unspecified.
The latter is not explicitly disallowed by tls_write(3), but libressl
implements tls_write with a call to SSL_write, which is documented
to have undefined behavior[1]:
> When calling SSL_write() with num=0 bytes to be sent, the behaviour
> is undefined.
[0] https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html
[1] https://man.openbsd.org/SSL_write.3
Diffstat:
M sacc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/sacc.c b/sacc.c
@@ -535,10 +535,10 @@ sendselector(struct cnx *c, const char *selector)
msg = p = xmalloc(ln);
snprintf(msg, ln--, "%s\r\n", selector);
- while ((n = iowrite(c, p, ln)) > 0) {
+ while (ln && (n = iowrite(c, p, ln)) > 0) {
ln -= n;
p += n;
- };
+ }
free(msg);
if (n == -1)
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.