mirror of https://github.com/ipxe/ipxe.git
[crypto] Avoid an error when asn1_shrink() is already at end of object
asn1_skip() will return an error on reaching the end of an object, and so should not be used as the basis for asn1_shrink(). Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/6/head
parent
2d9d0adc4e
commit
2cd24473b8
|
@ -220,16 +220,21 @@ int asn1_skip ( struct asn1_cursor *cursor, unsigned int type ) {
|
||||||
* invalidated.
|
* invalidated.
|
||||||
*/
|
*/
|
||||||
int asn1_shrink ( struct asn1_cursor *cursor, unsigned int type ) {
|
int asn1_shrink ( struct asn1_cursor *cursor, unsigned int type ) {
|
||||||
struct asn1_cursor next;
|
struct asn1_cursor temp;
|
||||||
int rc;
|
const void *end;
|
||||||
|
int len;
|
||||||
|
|
||||||
/* Skip to next object */
|
/* Find end of object */
|
||||||
memcpy ( &next, cursor, sizeof ( next ) );
|
memcpy ( &temp, cursor, sizeof ( temp ) );
|
||||||
if ( ( rc = asn1_skip ( &next, type ) ) != 0 )
|
len = asn1_start ( &temp, type );
|
||||||
return rc;
|
if ( len < 0 ) {
|
||||||
|
asn1_invalidate_cursor ( cursor );
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
end = ( temp.data + len );
|
||||||
|
|
||||||
/* Shrink original cursor to contain only its first object */
|
/* Shrink original cursor to contain only its first object */
|
||||||
cursor->len = ( next.data - cursor->data );
|
cursor->len = ( end - cursor->data );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue