> It's base64. 4/3 expansion; round it up and add padding. What's "nontrivial" about that?
If you mean ceil(inlen * 4/3) + 1 (even if you use exact arithmetic), then you are passing too small a buffer and you will overflow. Maybe your “add padding” part fixes it? In any case, I think that the fact that this confusion is even possible proves my point.
You should not need to read the manpage of a function you are calling in order to determine whether you have passed a large enough buffer to avoid overflow.
Reading the manpage to get the function to not return an error would be a different story.
If you mean ceil(inlen * 4/3) + 1 (even if you use exact arithmetic), then you are passing too small a buffer and you will overflow.
If you let untrusted input reach inlen and overflow that computation, you have already failed:
https://news.ycombinator.com/item?id=50570319