summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/krb5/asn.1/asn1_encode.c3
-rw-r--r--src/lib/krb5/asn.1/asn1_k_encode.c2
-rw-r--r--src/lib/krb5/asn.1/asn1buf.c29
-rw-r--r--src/lib/krb5/asn.1/asn1buf.h15
4 files changed, 20 insertions, 29 deletions
diff --git a/src/lib/krb5/asn.1/asn1_encode.c b/src/lib/krb5/asn.1/asn1_encode.c
index d2caefded..eaa40cf3a 100644
--- a/src/lib/krb5/asn.1/asn1_encode.c
+++ b/src/lib/krb5/asn.1/asn1_encode.c
@@ -421,7 +421,8 @@ encode_a_field(asn1buf *buf, const void *val,
{
unsigned int length;
- retval = asn1_encode_integer(buf, field->dataoff, &length);
+ retval = asn1_encode_integer(buf, (asn1_intmax) field->dataoff,
+ &length);
if (retval) return retval;
sum += length;
break;
diff --git a/src/lib/krb5/asn.1/asn1_k_encode.c b/src/lib/krb5/asn.1/asn1_k_encode.c
index a94ac3c4e..2f48b82b9 100644
--- a/src/lib/krb5/asn.1/asn1_k_encode.c
+++ b/src/lib/krb5/asn.1/asn1_k_encode.c
@@ -155,7 +155,7 @@ asn1_encode_krb5_flags_at(asn1buf *buf, const krb5_flags *val,
unsigned int *retlen)
{
unsigned char cbuf[4];
- store_32_be(*val, cbuf);
+ store_32_be((krb5_ui_4) *val, cbuf);
return asn1_encode_bitstring(buf, 4, cbuf, retlen);
}
DEFFNXTYPE(krb5_flags, krb5_flags, asn1_encode_krb5_flags_at);
diff --git a/src/lib/krb5/asn.1/asn1buf.c b/src/lib/krb5/asn.1/asn1buf.c
index 0779bfd2f..29a3f5c55 100644
--- a/src/lib/krb5/asn.1/asn1buf.c
+++ b/src/lib/krb5/asn.1/asn1buf.c
@@ -52,10 +52,17 @@
#define ASN1BUF_OMIT_INLINE_FUNCS
#include "asn1buf.h"
-#undef ASN1BUF_OMIT_INLINE_FUNCS
#include <stdio.h>
#include "asn1_get.h"
+#if !((__GNUC__ >= 2) && !defined(ASN1BUF_OMIT_INLINE_FUNCS)) || defined(CONFIG_SMALL)
+/* Declare private procedures as static if they're not used for inline
+ expansion of other stuff elsewhere. */
+static unsigned int asn1buf_free(const asn1buf *);
+static asn1_error_code asn1buf_ensure_space(asn1buf *, unsigned int);
+static asn1_error_code asn1buf_expand(asn1buf *, unsigned int);
+#endif
+
#define asn1_is_eoc(class, num, indef) \
((class) == UNIVERSAL && !(num) && !(indef))
@@ -318,8 +325,7 @@ asn1_error_code asn1buf_hex_unparse(const asn1buf *buf, char **s)
/****************************************************************/
/* Private Procedures */
-#undef asn1buf_size
-int asn1buf_size(const asn1buf *buf)
+static int asn1buf_size(const asn1buf *buf)
{
if (buf == NULL || buf->base == NULL) return 0;
return buf->bound - buf->base + 1;
@@ -336,11 +342,9 @@ unsigned int asn1buf_free(const asn1buf *buf)
asn1_error_code asn1buf_ensure_space(asn1buf *buf, const unsigned int amount)
{
unsigned int avail = asn1buf_free(buf);
- if (avail < amount) {
- asn1_error_code retval = asn1buf_expand(buf, amount-avail);
- if (retval) return retval;
- }
- return 0;
+ if (avail >= amount)
+ return 0;
+ return asn1buf_expand(buf, amount-avail);
}
asn1_error_code asn1buf_expand(asn1buf *buf, unsigned int inc)
@@ -354,12 +358,9 @@ asn1_error_code asn1buf_expand(asn1buf *buf, unsigned int inc)
if (inc < STANDARD_INCREMENT)
inc = STANDARD_INCREMENT;
- if (buf->base == NULL)
- buf->base = malloc((asn1buf_size(buf)+inc) * sizeof(asn1_octet));
- else
- buf->base = realloc(buf->base,
- (asn1buf_size(buf)+inc) * sizeof(asn1_octet));
- if (buf->base == NULL) return ENOMEM;
+ buf->base = realloc(buf->base,
+ (asn1buf_size(buf)+inc) * sizeof(asn1_octet));
+ if (buf->base == NULL) return ENOMEM; /* XXX leak */
buf->bound = (buf->base) + bound_offset + inc;
buf->next = (buf->base) + next_offset;
return 0;
diff --git a/src/lib/krb5/asn.1/asn1buf.h b/src/lib/krb5/asn.1/asn1buf.h
index 33578f98a..1e40cae7b 100644
--- a/src/lib/krb5/asn.1/asn1buf.h
+++ b/src/lib/krb5/asn.1/asn1buf.h
@@ -13,16 +13,7 @@ typedef struct code_buffer_rep {
/**************** Private Procedures ****************/
-int asn1buf_size
- (const asn1buf *buf);
-/* requires *buf has been created and not destroyed
- effects Returns the total size
- (in octets) of buf's octet buffer. */
-#define asn1buf_size(buf) \
- (((buf) == NULL || (buf)->base == NULL) \
- ? 0 \
- : ((buf)->bound - (buf)->base + 1))
-
+#if ((__GNUC__ >= 2) && !defined(ASN1BUF_OMIT_INLINE_FUNCS)) && !defined(CONFIG_SMALL)
unsigned int asn1buf_free
(const asn1buf *buf);
/* requires *buf is allocated
@@ -40,13 +31,10 @@ asn1_error_code asn1buf_ensure_space
effects If buf has less than amount octets of free space, then it is
expanded to have at least amount octets of free space.
Returns ENOMEM memory is exhausted. */
-#ifndef CONFIG_SMALL
#define asn1buf_ensure_space(buf,amount) \
((asn1buf_free(buf) < (amount)) \
? (asn1buf_expand((buf), (amount)-asn1buf_free(buf))) \
: 0)
-#endif
-
asn1_error_code asn1buf_expand
(asn1buf *buf, unsigned int inc);
@@ -54,6 +42,7 @@ asn1_error_code asn1buf_expand
modifies *buf
effects Expands *buf by allocating space for inc more octets.
Returns ENOMEM if memory is exhausted. */
+#endif
int asn1buf_len
(const asn1buf *buf);