Skip to content

Commit f734743

Browse files
committed
Improve error messages for bytea decoding failures.
Craig Ringer
1 parent 8522f21 commit f734743

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/backend/utils/adt/encode.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ b64_decode(const char *src, unsigned len, char *dst)
292292
else
293293
ereport(ERROR,
294294
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
295-
errmsg("unexpected \"=\"")));
295+
errmsg("unexpected \"=\" while decoding base64 sequence")));
296296
}
297297
b = 0;
298298
}
@@ -304,7 +304,7 @@ b64_decode(const char *src, unsigned len, char *dst)
304304
if (b < 0)
305305
ereport(ERROR,
306306
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
307-
errmsg("invalid symbol")));
307+
errmsg("invalid symbol '%c' while decoding base64 sequence", (int) c)));
308308
}
309309
/* add it to buffer */
310310
buf = (buf << 6) + b;
@@ -324,7 +324,8 @@ b64_decode(const char *src, unsigned len, char *dst)
324324
if (pos != 0)
325325
ereport(ERROR,
326326
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
327-
errmsg("invalid end sequence")));
327+
errmsg("invalid base64 end sequence"),
328+
errhint("input data is missing padding, truncated, or otherwise corrupted")));
328329

329330
return p - dst;
330331
}

0 commit comments

Comments
 (0)