summaryrefslogtreecommitdiffstats
path: root/lib/session.c
diff options
context:
space:
mode:
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2014-09-22 07:32:38 +0200
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2014-09-22 07:32:38 +0200
commitf06a022685699e608aa5e4157728f7f673aa2f89 (patch)
treeadde94746cf20d654e33269c6a71ed44002be6e7 /lib/session.c
parentfbed811be97ed18c068bd1e76d2a0c2a6f1eaf0e (diff)
Retry printing when sprintf fails (reported by Stig Thormodsrud)
Instead of returning the length of the string which would have been printed, sprintf sometimes simply returns an error code. Handle the case and flush the printing buffer and retry.
Diffstat (limited to 'lib/session.c')
-rw-r--r--lib/session.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/lib/session.c b/lib/session.c
index cbef026..da162b0 100644
--- a/lib/session.c
+++ b/lib/session.c
@@ -716,13 +716,7 @@ retry:
fmt, args);
va_end(args);
- if (ret < 0) {
- ipset_err(session,
- "Internal error at printing to output buffer");
- longjmp(printf_failure, 1);
- }
-
- if (ret >= IPSET_OUTBUFLEN - len) {
+ if (ret < 0 || ret >= IPSET_OUTBUFLEN - len) {
/* Buffer was too small, push it out and retry */
D("print buffer and try again: %u", len);
if (loop++) {
@@ -750,13 +744,7 @@ retry:
ret = fn(session->outbuf + len, IPSET_OUTBUFLEN - len,
session->data, opt, session->envopts);
- if (ret < 0) {
- ipset_err(session,
- "Internal error at printing to output buffer");
- longjmp(printf_failure, 1);
- }
-
- if (ret >= IPSET_OUTBUFLEN - len) {
+ if (ret < 0 || ret >= IPSET_OUTBUFLEN - len) {
/* Buffer was too small, push it out and retry */
D("print buffer and try again: %u", len);
if (loop++) {