Index: libraries/libldap/gssapi.c =================================================================== RCS file: /repo/OpenLDAP/pkg/ldap/libraries/libldap/gssapi.c,v retrieving revision 1.1 diff -u -2 -r1.1 libraries/libldap/gssapi.c --- libraries/libldap/gssapi.c 9 Oct 2008 09:10:28 -0000 1.1 +++ libraries/libldap/gssapi.c 13 Oct 2008 09:50:48 -0000 @@ -72,10 +72,10 @@ mech, &msg_ctx, &minor_msg); - snprintf(buf, buf_len, "gss_rc[%d:%*s] mech[%*s] minor[%u:%*s]", + snprintf(buf, buf_len, "gss_rc[%d:%*s] mech[%*s] minor[%lu:%*s]", gss_rc, (int)gss_msg.length, (const char *)(gss_msg.value?gss_msg.value:""), (int)mech_msg.length, (const char *)(mech_msg.value?mech_msg.value:""), - minor_status, (int)minor_msg.length, + (unsigned long)minor_status, (int)minor_msg.length, (const char *)(minor_msg.value?minor_msg.value:"")); @@ -211,5 +211,5 @@ ber_log_printf( LDAP_DEBUG_ANY, p->sbiod->sbiod_sb->sb_debug, "sb_sasl_gssapi_encode: failed to grow the buffer to %lu bytes\n", - pkt_len ); + (unsigned long) pkt_len ); return -1; } @@ -283,4 +283,6 @@ } + pkt_len = 4 + wrapped.length; /* ??? just coped from sb_sasl_gssapi_encode(), I don't know if that's right */ + /* Grow the packet buffer if neccessary */ if ( dst->buf_size < unwrapped.length && @@ -289,5 +291,5 @@ ber_log_printf( LDAP_DEBUG_ANY, p->sbiod->sbiod_sb->sb_debug, "sb_sasl_gssapi_decode: failed to grow the buffer to %lu bytes\n", - pkt_len ); + (unsigned long) pkt_len ); return -1; } @@ -515,7 +517,7 @@ int gss_rc; int ret; - size_t svc_principal_size; + size_t svc_principal_len; char *svc_principal = NULL; - const char *principal_fmt = NULL; + const char *principal_prefix; const char *str = NULL; const char *givenstr = NULL; @@ -540,30 +542,23 @@ if (allow_remote && givenstr) { - principal_fmt = "%s"; - svc_principal_size = strlen(givenstr) + 1; + principal_prefix = ""; str = givenstr; } else if (allow_remote && dnsHostName) { - principal_fmt = "ldap/%s"; - svc_principal_size = strlen(dnsHostName) + strlen(principal_fmt); + principal_prefix = "ldap/"; str = dnsHostName; } else { - principal_fmt = "ldap/%s"; - svc_principal_size = strlen(host) + strlen(principal_fmt); + principal_prefix = "ldap/"; str = host; } - svc_principal = (char*) ldap_memalloc(svc_principal_size * sizeof(char)); - if ( ret < 0 ) { + svc_principal_len = strlen( principal_prefix ) + strlen( str ); + svc_principal = (char *) ldap_memalloc( svc_principal_len + 1 ); + if ( svc_principal == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; return ld->ld_errno; } - - ret = snprintf( svc_principal, svc_principal_size - 1, principal_fmt, str); - if (ret < 0 || ret >= svc_principal_size - 1) { - ld->ld_errno = LDAP_LOCAL_ERROR; - return ld->ld_errno; - } + sprintf( svc_principal, "%s%s", principal_prefix, str ); Debug( LDAP_DEBUG_TRACE, "principal for host[%s]: '%s'\n", @@ -571,5 +566,5 @@ input_name.value = svc_principal; - input_name.length = strlen( svc_principal ); + input_name.length = svc_principal_len; gss_rc = gss_import_name( &minor_status, &input_name, &nt_principal, principal );