Commit 47595927 authored by Geoff Simmons's avatar Geoff Simmons

Revert "set ENOMEM consistently (I hope everywhere)"

This reverts commit c47dcc40.

This was only set for encoders, but the contract for encoders in
vmod_blobcode.h does not require setting errno, and it isn't
necessary, since insufficient space is the only cause for
encoders to fail (callers don't check errno, and don't need to).
parent 3482fa99
Pipeline #29 skipped
......@@ -84,10 +84,8 @@ hex_encode(const enum encoding enc, char *restrict const buf,
assert(enc == HEXUC || enc == HEXLC);
if (in == NULL || inlen == 0)
return 0;
if (buflen < hex_encode_l(inlen)) {
errno = ENOMEM;
if (buflen < hex_encode_l(inlen))
return -1;
}
if (enc != HEXLC)
alphabet = hex_alphabet[1];
......
......@@ -55,10 +55,8 @@ id_encode(const enum encoding enc, char *restrict const buf,
(void) enc;
AN(buf);
if (buflen < inlen + 1) {
errno = ENOMEM;
if (buflen < inlen + 1)
return -1;
}
if (in == NULL || inlen == 0)
return 0;
......
......@@ -95,17 +95,13 @@ url_encode(const enum encoding enc, char *restrict const buf,
for (int i = 0; i < inlen; i++) {
if (isunreserved(in[i])) {
if (p == end) {
errno = ENOMEM;
if (p == end)
return -1;
}
*p++ = in[i];
}
else {
if (p + 3 > end) {
errno = ENOMEM;
if (p + 3 > end)
return -1;
}
*p++ = '%';
*p++ = alphabet[(in[i] & 0xf0) >> 4];
*p++ = alphabet[in[i] & 0x0f];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment