File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
hadoop-common-project/hadoop-nfs/src
main/java/org/apache/hadoop/oncrpc/security
test/java/org/apache/hadoop/oncrpc/security Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,10 @@ public int[] getAuxGIDs() {
6363 return mAuxGIDs ;
6464 }
6565
66+ public int getStamp () {
67+ return mStamp ;
68+ }
69+
6670 public void setGID (int gid ) {
6771 this .mGID = gid ;
6872 }
@@ -93,8 +97,15 @@ public void read(XDR xdr) {
9397
9498 @ Override
9599 public void write (XDR xdr ) {
100+ int padding = 0 ;
101+ // we do not need compute padding if the hostname is already a multiple of 4
102+ if (mHostName .getBytes (Charsets .UTF_8 ).length != 0 ) {
103+ padding = 4 - (mHostName .getBytes (Charsets .UTF_8 ).length % 4 );
104+ }
96105 // mStamp + mHostName.length + mHostName + mUID + mGID + mAuxGIDs.count
97106 mCredentialsLength = 20 + mHostName .getBytes (Charsets .UTF_8 ).length ;
107+ // add the extra padding to the credential length where hostname is not a multiple of 4
108+ mCredentialsLength = mCredentialsLength + padding ;
98109 // mAuxGIDs
99110 if (mAuxGIDs != null && mAuxGIDs .length > 0 ) {
100111 mCredentialsLength += mAuxGIDs .length * 4 ;
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ public void testReadWrite() {
3333 CredentialsSys credential = new CredentialsSys ();
3434 credential .setUID (0 );
3535 credential .setGID (1 );
36+ credential .setStamp (1234 );
3637
3738 XDR xdr = new XDR ();
3839 credential .write (xdr );
@@ -42,5 +43,6 @@ public void testReadWrite() {
4243
4344 assertEquals (0 , newCredential .getUID ());
4445 assertEquals (1 , newCredential .getGID ());
46+ assertEquals (1234 , newCredential .getStamp ());
4547 }
4648}
You can’t perform that action at this time.
0 commit comments