File tree Expand file tree Collapse file tree 4 files changed +23
-10
lines changed
Expand file tree Collapse file tree 4 files changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -110,11 +110,11 @@ class KfsKrb5
110110 return EINVAL;
111111 }
112112 krb5_data theData = {0 };
113- krb5_error_code theRet = krb5_data_alloc (&theData, strlen (theStr));
113+ krb5_error_code theRet = krb5_data_copy (
114+ &theData, theStr, strlen (theStr) + 1 );
114115 if (theRet) {
115116 return theRet;
116117 }
117- memcpy (theData.data , theStr, theData.length );
118118 theRet = krb5_get_server_rcache (inCtx, &theData, inRCache);
119119 krb5_data_free (&theData);
120120 return theRet;
Original file line number Diff line number Diff line change @@ -161,17 +161,31 @@ class KrbClient::Impl
161161 if (theCredsPtr) {
162162 mLastCredEndTime = theCredsPtr->times .endtime ;
163163 }
164+ if (0 == mErrCode ) {
165+ mErrCode = krb5_auth_con_getkey (mCtx , mAuthCtx , &mKeyBlockPtr );
166+ }
167+ #ifdef KRB5_HAS_krb5_creds_keyblock
168+ if (0 == mErrCode && ! mKeyBlockPtr ) {
169+ mErrCode = krb5_copy_keyblock (
170+ mCtx , &theCredsPtr->keyblock , &mKeyBlockPtr );
171+ }
172+ #endif
164173 krb5_free_creds (mCtx , theCredsPtr);
165- if (mErrCode != 0 ) {
174+ if (0 != mErrCode ) {
166175 return ErrStr ();
167176 }
168- if ((mErrCode = krb5_auth_con_getkey (mCtx , mAuthCtx , &mKeyBlockPtr ))) {
169- return ErrStr ();
177+ if (0 == mErrCode && ! mKeyBlockPtr ) {
178+ mErrCode = EINVAL;
179+ return " no session key" ;
170180 }
171- outDataPtr = (const char *)mOutBuf .data ;
172- outDataLen = (int )mOutBuf .length ;
173181 outSessionKeyPtr = KfsKrb5::get_key_block_contents (mKeyBlockPtr );
174182 outSessionKeyLen = KfsKrb5::get_key_block_length (mKeyBlockPtr );
183+ if (! outSessionKeyPtr || outSessionKeyLen <= 0 ) {
184+ mErrCode = EINVAL;
185+ return " invalid empty session key" ;
186+ }
187+ outDataPtr = (const char *)mOutBuf .data ;
188+ outDataLen = (int )mOutBuf .length ;
175189 return 0 ;
176190 }
177191 const char * Reply (
Original file line number Diff line number Diff line change 3434
3535#include < time.h>
3636#include < iostream>
37- #include < vector>
3837#include < string>
3938
4039namespace
Original file line number Diff line number Diff line change @@ -520,8 +520,8 @@ class AuthContext::Impl
520520 // No replay detection is needed, as either AP_REP or TLS-PSK
521521 // are used. Both these mechanisms are sufficient to protect
522522 // against replay attack as both provide mutual authentication.
523- // With no TLS once assume that party other than QFS protects
524- // against replay, man-in-the-middle attacks etc.
523+ // With no TLS one assumes that the party other than QFS
524+ // protects against replay, man-in-the-middle attacks etc.
525525 theKrbServicePtr.reset (new KrbService ());
526526 const char * theErrMsgPtr = theKrbServicePtr->Init (
527527 inParameters.getValue (
You can’t perform that action at this time.
0 commit comments