Sorry to give wrong reference.

The tempnam() doesn't indeed claim the length of the suffix, and it's just the current implementation that defines a 6-chars one
(https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/posix/tempname.c;h=c49a42e20ebe5df296b5605559f8d6ddfaac8bd2;hb=HEAD), so I would agree to prevent the length of query from exceeding the size limitation if you still want to.

However, tempnam() is used to acquire a unique file name in a given directory, so I prefer expand the query string buffer to hold the longest file name rather than have the file name truncated.

what's your opinion?