| 44 | #if USE_KRB5 |
| 45 | |
| 46 | String bufferToString(const gss_buffer_desc & buf) |
| 47 | { |
| 48 | // Copy the GSS buffer verbatim. Do not strip trailing NULs: some callers (notably |
| 49 | // output_token_buf from gss_accept_sec_context, which carries an encrypted AP-REP in |
| 50 | // SPNEGO) pass opaque binary data where trailing 0x00 bytes are meaningful. Display |
| 51 | // strings from gss_display_status / gss_display_name have buf.length excluding the |
| 52 | // NUL terminator on MIT krb5 and Heimdal, so no trimming is needed there either. |
| 53 | String str; |
| 54 | |
| 55 | if (buf.length > 0 && buf.value != nullptr) |
| 56 | str.assign(static_cast<char *>(buf.value), buf.length); |
| 57 | |
| 58 | return str; |
| 59 | } |
| 60 | |
| 61 | namespace |
| 62 | { |