summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Layton <jlayton@samba.org>2012-04-15 08:14:59 -0400
committerJeff Layton <jlayton@samba.org>2012-04-15 08:14:59 -0400
commit730af950428eab6fd131b560a3ee41f4d5fbf405 (patch)
tree33083e1acdcfeb38239d747ff7957b716fd19483
parentea9407fc4ae72a5d4245cbb25f7429f46d664d23 (diff)
downloadcifs-utils-730af950428eab6fd131b560a3ee41f4d5fbf405.tar.gz
cifs-utils-730af950428eab6fd131b560a3ee41f4d5fbf405.tar.bz2
cifs-utils-730af950428eab6fd131b560a3ee41f4d5fbf405.zip
asn1: fix up some compiler warnings in asn1.c
These have been around for quite some time. gcc -DHAVE_CONFIG_H -I. -Wall -Wextra -g -O2 -MT asn1.o -MD -MP -MF .deps/asn1.Tpo -c -o asn1.o asn1.c asn1.c: In function ‘asn1_write’: asn1.c:45:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] asn1.c: In function ‘asn1_peek’: asn1.c:411:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] asn1.c: In function ‘asn1_tag_remaining’: asn1.c:541:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] asn1.c: In function ‘_ber_read_OID_String_impl’: asn1.c:570:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] Almost all of these are due to the fact that asn1_data->ofs is a signed value, and ->length is unsigned. This should clear the way to add -Werror to the cflags in the near future. Signed-off-by: Jeff Layton <jlayton@samba.org>
-rw-r--r--asn1.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/asn1.c b/asn1.c
index 4103419..a00c474 100644
--- a/asn1.c
+++ b/asn1.c
@@ -41,8 +41,9 @@ void asn1_free(struct asn1_data *data)
/* write to the ASN1 buffer, advancing the buffer pointer */
bool asn1_write(struct asn1_data *data, const void *p, int len)
{
- if (data->has_error) return false;
- if (data->length < data->ofs+len) {
+ if (data->has_error)
+ return false;
+ if (data->length < (size_t)data->ofs + len) {
uint8_t *newp;
newp = talloc_realloc(data, data->data, uint8_t, data->ofs+len);
if (!newp) {
@@ -408,7 +409,7 @@ bool asn1_peek(struct asn1_data *data, void *p, int len)
if (len < 0 || data->ofs + len < data->ofs || data->ofs + len < len)
return false;
- if (data->ofs + len > data->length) {
+ if ((size_t)data->ofs + len > data->length) {
/* we need to mark the buffer as consumed, so the caller knows
this was an out of data error, and not a decode error */
data->ofs = data->length;
@@ -538,7 +539,11 @@ int asn1_tag_remaining(struct asn1_data *data)
return -1;
}
remaining = data->nesting->taglen - (data->ofs - data->nesting->start);
- if (remaining > (data->length - data->ofs)) {
+ if (remaining < 0) {
+ data->has_error = true;
+ return -1;
+ }
+ if ((size_t)remaining > data->length - data->ofs) {
data->has_error = true;
return -1;
}
@@ -553,7 +558,7 @@ int asn1_tag_remaining(struct asn1_data *data)
static bool _ber_read_OID_String_impl(TALLOC_CTX *mem_ctx, DATA_BLOB blob,
const char **OID, size_t *bytes_eaten)
{
- int i;
+ unsigned int i;
uint8_t *b;
unsigned int v;
char *tmp_oid = NULL;