asn1: Add some early returns
authorVolker Lendecke <vl@samba.org>
Sun, 27 Dec 2015 09:57:07 +0000 (10:57 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 5 Jan 2016 23:54:17 +0000 (00:54 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/util/asn1.c

index 6f51820949a2382ef3790b71282042dd368f1920..d8d0f9994ee9c99679015ec6decf1b03d03108e8 100644 (file)
@@ -72,7 +72,9 @@ bool asn1_push_tag(struct asn1_data *data, uint8_t tag)
 {
        struct nesting *nesting;
 
-       asn1_write_uint8(data, tag);
+       if (!asn1_write_uint8(data, tag)) {
+               return false;
+       }
        nesting = talloc(data, struct nesting);
        if (!nesting) {
                data->has_error = true;
@@ -91,6 +93,10 @@ bool asn1_pop_tag(struct asn1_data *data)
        struct nesting *nesting;
        size_t len;
 
+       if (data->has_error) {
+               return false;
+       }
+
        nesting = data->nesting;
 
        if (!nesting) {
@@ -190,6 +196,10 @@ static bool push_int_bigendian(struct asn1_data *data, unsigned int i, bool nega
 
 bool asn1_write_implicit_Integer(struct asn1_data *data, int i)
 {
+       if (data->has_error) {
+               return false;
+       }
+
        if (i == -1) {
                /* -1 is special as it consists of all-0xff bytes. In
                     push_int_bigendian this is the only case that is not