File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 88 * Copyright (c) 2016 Mellanox Technologies, Inc.
99 * All rights reserved.
1010 * Copyright (c) 2016 Cisco Systems, Inc. All rights reserved.
11+ * Copyright (c) 2020 Triad National Security, LLC. All rights
12+ * reserved.
1113 * $COPYRIGHT$
1214 *
1315 * Additional copyrights may follow
@@ -663,9 +665,11 @@ static inline unsigned char pmi_base64_decsym (unsigned char value) {
663665
664666static inline void pmi_base64_encode_block (const unsigned char in [3 ], char out [4 ], int len ) {
665667 out [0 ] = pmi_base64_encsym (in [0 ] >> 2 );
666- out [1 ] = pmi_base64_encsym (((in [0 ] & 0x03 ) << 4 ) | ((in [1 ] & 0xf0 ) >> 4 ));
668+ /* len == length of in[] - conditionals insure we don't reference uninitialized in[] values */
669+ out [1 ] = 1 < len ? pmi_base64_encsym (((in [0 ] & 0x03 ) << 4 ) | ((in [1 ] & 0xf0 ) >> 4 )) : pmi_base64_encsym ((in [0 ] & 0x03 ) << 4 );
667670 /* Cray PMI doesn't allow = in PMI attributes so pad with spaces */
668- out [2 ] = 1 < len ? pmi_base64_encsym (((in [1 ] & 0x0f ) << 2 ) | ((in [2 ] & 0xc0 ) >> 6 )) : ' ' ;
671+ out [2 ] = 1 < len ? pmi_base64_encsym ((in [1 ] & 0x0f ) << 2 ) : ' ' ;
672+ out [2 ] = 2 < len ? pmi_base64_encsym (((in [1 ] & 0x0f ) << 2 ) | ((in [2 ] & 0xc0 ) >> 6 )) : out [2 ];
669673 out [3 ] = 2 < len ? pmi_base64_encsym (in [2 ] & 0x3f ) : ' ' ;
670674}
671675
You can’t perform that action at this time.
0 commit comments