diff options
Diffstat (limited to 'shared/systemd/src/basic/hexdecoct.c')
-rw-r--r-- | shared/systemd/src/basic/hexdecoct.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/shared/systemd/src/basic/hexdecoct.c b/shared/systemd/src/basic/hexdecoct.c index ffd9a8f60f..7c66cc6285 100644 --- a/shared/systemd/src/basic/hexdecoct.c +++ b/shared/systemd/src/basic/hexdecoct.c @@ -606,10 +606,11 @@ static int base64_append_width( lines = DIV_ROUND_UP(len, width); slen = strlen_ptr(sep); - if (lines > (SSIZE_MAX - plen - 1 - slen) / (indent + width + 1)) + if (plen >= SSIZE_MAX - 1 - slen || + lines > (SSIZE_MAX - plen - 1 - slen) / (indent + width + 1)) return -ENOMEM; - t = realloc(*prefix, plen + 1 + slen + (indent + width + 1) * lines); + t = realloc(*prefix, (ssize_t) plen + 1 + slen + (indent + width + 1) * lines); if (!t) return -ENOMEM; @@ -644,7 +645,7 @@ int base64_append( return base64_append_width(prefix, plen, "\n", indent, p, l, width - indent - 1); else /* leave plen on the left, keep last column free */ - return base64_append_width(prefix, plen, NULL, plen, p, l, width - plen - 1); + return base64_append_width(prefix, plen, " ", plen, p, l, width - plen - 1); } #endif /* NM_IGNORED */ |