mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-07 08:56:17 +08:00
Fix asn1_bit_string_from_der_ex bug
from https://github.com/vita1984 文件:asn1.c 函数名:asn1_bit_string_from_der_ex BUG描述:nbits的值没有减去unused_bits部分的值导致nbits值错误 复现方式: ASN hex值:03 02 06 aa 返回值照理应该是2bit。但当前函数实际返回8bit。 修改方式: 原代码: -- *nbits = (len - 1) << 3; 修改为: *nbits = (((len - 1) << 3) - unused_bits); 建议把unused_bits的int类型修改为size_t类型
This commit is contained in:
@@ -1147,7 +1147,7 @@ int asn1_bit_string_from_der_ex(int tag, const uint8_t **bits, size_t *nbits, co
|
||||
}
|
||||
|
||||
(*bits)++;
|
||||
*nbits = (len - 1) << 3;
|
||||
*nbits = ((len - 1) << 3) - unused_bits; // FIXME: need more tests
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user