- tests: Added self-test of bit string functions.
- build: Added windows/libtasn14win.mk rules to produce Windows binaries.
- build: Don't hard code path to perl in doc/gdoc.
+- build: Now builds without compiler warnings with Solaris CC.
* Noteworthy changes in release 2.10 (2011-10-25) [stable]
- lib: Small optimization, possibly working around gcc/valgrind issue.
done
gl_WARN_ADD([-Wno-missing-field-initializers])
- gl_WARN_ADD([-Wno-sign-compare])
- gl_WARN_ADD([-Wno-pointer-sign])
gl_WARN_ADD([-Wno-unused-parameter])
gl_WARN_ADD([-Wno-stack-protector]) # Some functions cannot be protected
gl_WARN_ADD([-fdiagnostics-show-option])
{
int len_len;
int max_len;
+ int str_len = _asn1_strlen (str);
max_len = *der_len;
- asn1_length_der (strlen (str), (max_len > 0) ? der : NULL, &len_len);
+ asn1_length_der (str_len, (max_len > 0) ? der : NULL, &len_len);
- if ((len_len + (int) strlen (str)) <= max_len)
- memcpy (der + len_len, str, strlen (str));
- *der_len = len_len + strlen (str);
+ if ((len_len + str_len) <= max_len)
+ memcpy (der + len_len, str, str_len);
+ *der_len = len_len + str_len;
if ((*der_len) > max_len)
return ASN1_MEM_ERROR;
char *temp, *n_end, *n_start;
unsigned char bit7;
unsigned long val, val1 = 0;
- int str_len = strlen(str);
+ int str_len = _asn1_strlen(str);
max_len = *der_len;
int tag_len, is_tag_implicit;
unsigned char class, class_implicit = 0, temp[SIZEOF_UNSIGNED_INT * 3 + 1];
unsigned long tag_implicit = 0;
- char tag_der[MAX_TAG_LEN];
+ unsigned char tag_der[MAX_TAG_LEN];
is_tag_implicit = 0;
&tag_len);
else
_asn1_tag_der (class | ASN1_CLASS_STRUCTURED,
- strtoul (p->value, NULL, 10), tag_der,
- &tag_len);
+ _asn1_strtoul (p->value, NULL, 10),
+ tag_der, &tag_len);
*max_len -= tag_len;
if (*max_len >= 0)
memcpy (der + *counter, tag_der, tag_len);
*counter += tag_len;
- _asn1_ltostr (*counter, temp);
- _asn1_set_name (p, temp);
+ _asn1_ltostr (*counter, (char *) temp);
+ _asn1_set_name (p, (const char *) temp);
is_tag_implicit = 0;
}
(type_field (node->type) == TYPE_SET_OF))
class |= ASN1_CLASS_STRUCTURED;
class_implicit = class;
- tag_implicit = strtoul (p->value, NULL, 10);
+ tag_implicit = _asn1_strtoul (p->value, NULL, 10);
is_tag_implicit = 1;
}
}
char *ErrorDescription)
{
ASN1_TYPE node, p, p2;
- char temp[SIZEOF_UNSIGNED_LONG_INT * 3 + 1];
+ unsigned char temp[SIZEOF_UNSIGNED_LONG_INT * 3 + 1];
int counter, counter_old, len2, len3, tlen, move, max_len, max_len_old;
asn1_retCode err;
unsigned char *der = ider;
case TYPE_SET:
if (move != UP)
{
- _asn1_ltostr (counter, temp);
- tlen = strlen (temp);
+ _asn1_ltostr (counter, (char *) temp);
+ tlen = _asn1_strlen (temp);
if (tlen > 0)
_asn1_set_value (p, temp, tlen + 1);
if (p->down == NULL)
}
else
{ /* move==UP */
- len2 = strtol (p->value, NULL, 10);
+ len2 = _asn1_strtol (p->value, NULL, 10);
_asn1_set_value (p, NULL, 0);
if ((type_field (p->type) == TYPE_SET) && (max_len >= 0))
_asn1_ordering_set (der + len2, max_len - len2, p);
case TYPE_SET_OF:
if (move != UP)
{
- _asn1_ltostr (counter, temp);
- tlen = strlen (temp);
+ _asn1_ltostr (counter, (char *) temp);
+ tlen = _asn1_strlen (temp);
if (tlen > 0)
_asn1_set_value (p, temp, tlen + 1);
}
if (move == UP)
{
- len2 = strtol (p->value, NULL, 10);
+ len2 = _asn1_strtol (p->value, NULL, 10);
_asn1_set_value (p, NULL, 0);
if ((type_field (p->type) == TYPE_SET_OF)
&& (max_len - len2 > 0))
if (p->type & CONST_SET)
{
p2 = _asn1_find_up (p);
- len2 = strtol (p2->value, NULL, 10);
+ len2 = _asn1_strtol (p2->value, NULL, 10);
if (len2 == -1)
{
if (!der[counter] && !der[counter + 1])
if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
{
p2 = _asn1_find_up (p);
- len2 = strtol (p2->value, NULL, 10);
+ len2 = _asn1_strtol (p2->value, NULL, 10);
if (counter == len2)
{
if (p->right)
if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
{
p2 = _asn1_find_up (p);
- len2 = strtol (p2->value, NULL, 10);
+ len2 = _asn1_strtol (p2->value, NULL, 10);
if ((len2 != -1) && (counter > len2))
ris = ASN1_TAG_ERROR;
}
case TYPE_SET:
if (move == UP)
{
- len2 = strtol (p->value, NULL, 10);
+ len2 = _asn1_strtol (p->value, NULL, 10);
_asn1_set_value (p, NULL, 0);
if (len2 == -1)
{ /* indefinite length method */
case TYPE_SET_OF:
if (move == UP)
{
- len2 = strtol (p->value, NULL, 10);
+ len2 = _asn1_strtol (p->value, NULL, 10);
if (len2 == -1)
{ /* indefinite length method */
if ((counter + 2) > len)
if (p->type & CONST_SET)
{
p2 = _asn1_find_up (p);
- len2 = strtol (p2->value, NULL, 10);
+ len2 = _asn1_strtol (p2->value, NULL, 10);
if (counter == len2)
{
p = p2;
if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
{
p2 = _asn1_find_up (p);
- len2 = strtol (p2->value, NULL, 10);
+ len2 = _asn1_strtol (p2->value, NULL, 10);
if (counter == len2)
{
if (p->right)
if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
{
p2 = _asn1_find_up (p);
- len2 = strtol (p2->value, NULL, 10);
+ len2 = _asn1_strtol (p2->value, NULL, 10);
if (counter > len2)
ris = ASN1_TAG_ERROR;
}
case TYPE_SET:
if (move == UP)
{
- len2 = strtol (p->value, NULL, 10);
+ len2 = _asn1_strtol (p->value, NULL, 10);
_asn1_set_value (p, NULL, 0);
if (len2 == -1)
{ /* indefinite length method */
case TYPE_SET_OF:
if (move == UP)
{
- len2 = strtol (p->value, NULL, 10);
+ len2 = _asn1_strtol (p->value, NULL, 10);
if (len2 > counter)
{
_asn1_append_sequence_set (p);
if (p->type & CONST_SET)
{
p2 = _asn1_find_up (p);
- len2 = strtol (p2->value, NULL, 10);
+ len2 = _asn1_strtol (p2->value, NULL, 10);
if (len2 == -1)
{
if (!der[counter] && !der[counter + 1])
asn1_read_value (definitions, name, value, &len);
if ((result == ASN1_SUCCESS)
- && (!strcmp (p3->value, value)))
+ && (!_asn1_strcmp (p3->value, value)))
{
p2 = p2->right; /* pointer to the structure to
use for expansion */
result = asn1_read_value (definitions, name, value, &len);
if ((result == ASN1_SUCCESS)
- && (!strcmp (objectNode->value, value)))
+ && (!_asn1_strcmp (objectNode->value, value)))
{
p2 = p2->right; /* pointer to the structure to
/* Return: ASN1_MEM_ERROR or ASN1_SUCCESS */
/******************************************************************/
asn1_retCode
-_asn1_convert_integer (const char *value, unsigned char *value_out,
+_asn1_convert_integer (const unsigned char *value, unsigned char *value_out,
int value_out_size, int *len)
{
char negative;
long valtmp;
int k, k2;
- valtmp = strtol (value, NULL, 10);
+ valtmp = _asn1_strtol (value, NULL, 10);
for (k = 0; k < SIZEOF_UNSIGNED_LONG_INT; k++)
{
switch (type_field (node->type))
{
case TYPE_BOOLEAN:
- if (!strcmp (value, "TRUE"))
+ if (!_asn1_strcmp (value, "TRUE"))
{
if (node->type & CONST_DEFAULT)
{
else
_asn1_set_value (node, "T", 1);
}
- else if (!strcmp (value, "FALSE"))
+ else if (!_asn1_strcmp (value, "FALSE"))
{
if (node->type & CONST_DEFAULT)
{
{
if (type_field (p->type) == TYPE_CONSTANT)
{
- if ((p->name) && (!strcmp (p->name, value)))
+ if ((p->name) && (!_asn1_strcmp (p->name, value)))
{
value_temp =
(unsigned char *)
{
if (type_field (p2->type) == TYPE_CONSTANT)
{
- if ((p2->name) && (!strcmp (p2->name, p->value)))
+ if ((p2->name) && (!_asn1_strcmp (p2->name, p->value)))
{
default_temp =
(unsigned char *)
_asn1_free (value_temp);
break;
case TYPE_OBJECT_ID:
- for (i = 0; i < strlen (value); i++)
+ for (i = 0; i < _asn1_strlen (value); i++)
if ((!isdigit (value[i])) && (value[i] != '.') && (value[i] != '+'))
return ASN1_VALUE_NOT_VALID;
if (node->type & CONST_DEFAULT)
p = node->down;
while (type_field (p->type) != TYPE_DEFAULT)
p = p->right;
- if (!strcmp (value, p->value))
+ if (!_asn1_strcmp (value, p->value))
{
_asn1_set_value (node, NULL, 0);
break;
}
}
- _asn1_set_value (node, value, strlen (value) + 1);
+ _asn1_set_value (node, value, _asn1_strlen (value) + 1);
break;
case TYPE_TIME:
if (node->type & CONST_UTC)
{
- if (strlen (value) < 11)
+ if (_asn1_strlen (value) < 11)
return ASN1_VALUE_NOT_VALID;
for (k = 0; k < 10; k++)
if (!isdigit (value[k]))
return ASN1_VALUE_NOT_VALID;
- switch (strlen (value))
+ switch (_asn1_strlen (value))
{
case 11:
if (value[10] != 'Z')
default:
return ASN1_VALUE_NOT_FOUND;
}
- _asn1_set_value (node, value, strlen (value) + 1);
+ _asn1_set_value (node, value, _asn1_strlen (value) + 1);
}
else
{ /* GENERALIZED TIME */
if (value)
- _asn1_set_value (node, value, strlen (value) + 1);
+ _asn1_set_value (node, value, _asn1_strlen (value) + 1);
}
break;
case TYPE_OCTET_STRING:
if (len == 0)
- len = strlen (value);
+ len = _asn1_strlen (value);
_asn1_set_value_octet (node, value, len);
break;
case TYPE_GENERALSTRING:
if (len == 0)
- len = strlen (value);
+ len = _asn1_strlen (value);
_asn1_set_value_octet (node, value, len);
break;
case TYPE_BIT_STRING:
if (len == 0)
- len = strlen (value);
+ len = _asn1_strlen (value);
asn1_length_der ((len >> 3) + 2, NULL, &len2);
temp = (unsigned char *) _asn1_malloc ((len >> 3) + 2 + len2);
if (temp == NULL)
p = node->down;
while (p)
{
- if (!strcmp (p->name, value))
+ if (!_asn1_strcmp (p->name, value))
{
p2 = node->down;
while (p2)
break;
case TYPE_SEQUENCE_OF:
case TYPE_SET_OF:
- if (strcmp (value, "NEW"))
+ if (_asn1_strcmp (value, "NEW"))
return ASN1_VALUE_NOT_VALID;
_asn1_append_sequence_set (node);
break;
}
#define PUT_STR_VALUE( ptr, ptr_size, data) \
- *len = strlen(data) + 1; \
+ *len = _asn1_strlen(data) + 1; \
if (ptr_size < *len) { \
return ASN1_MEM_ERROR; \
} else { \
/* this strcpy is checked */ \
- strcpy(ptr, data); \
+ _asn1_strcpy(ptr, data); \
}
#define ADD_STR_VALUE( ptr, ptr_size, data) \
- *len = (int) strlen(data) + 1; \
- if (ptr_size < (int) strlen(ptr)+(*len)) { \
+ *len = (int) _asn1_strlen(data) + 1; \
+ if (ptr_size < (int) _asn1_strlen(ptr)+(*len)) { \
return ASN1_MEM_ERROR; \
} else { \
/* this strcat is checked */ \
- strcat(ptr, data); \
+ _asn1_strcat(ptr, data); \
}
/**
{
if (type_field (p2->type) == TYPE_CONSTANT)
{
- if ((p2->name) && (!strcmp (p2->name, p->value)))
+ if ((p2->name) && (!_asn1_strcmp (p2->name, p->value)))
{
if (_asn1_convert_integer
(p2->value, value, value_size,
}
p = p->right;
}
- *len = strlen (value) + 1;
+ *len = _asn1_strlen (value) + 1;
}
else if ((node->type & CONST_DEFAULT) && (node->value == NULL))
{
if (pTag)
{
- *tagValue = strtoul (pTag->value, NULL, 10);
+ *tagValue = _asn1_strtoul (pTag->value, NULL, 10);
if (pTag->type & CONST_APPLICATION)
*classValue = ASN1_CLASS_APPLICATION;
asn1_retCode _asn1_append_sequence_set (ASN1_TYPE node);
-asn1_retCode _asn1_convert_integer (const char *value,
+asn1_retCode _asn1_convert_integer (const unsigned char *value,
unsigned char *value_out,
int value_out_size, int *len);
#define _asn1_calloc calloc
#define _asn1_realloc realloc
#define _asn1_strdup strdup
+#define _asn1_strlen(s) strlen((const char *) s)
+#define _asn1_strtol(n,e,b) strtol((const char *) n, e, b)
+#define _asn1_strtoul(n,e,b) strtoul((const char *) n, e, b)
+#define _asn1_strcmp(a,b) strcmp((const char *)a, (const char *)b)
+#define _asn1_strcpy(a,b) strcpy((char *)a, (const char *)b)
+#define _asn1_strcat(a,b) strcat((char *)a, (const char *)b)
#define MAX_LOG_SIZE 1024 /* maximum number of characters of a log message */
{
_asn1_str_cpy (name2, sizeof (name2), name_root);
_asn1_str_cat (name2, sizeof (name2), ".");
- _asn1_str_cat (name2, sizeof (name2), p2->value);
+ _asn1_str_cat (name2, sizeof (name2), (char *) p2->value);
p3 = asn1_find_node (node, name2);
if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) ||
!(p3->type & CONST_ASSIGN))
{
p5 = _asn1_add_node_only (TYPE_CONSTANT);
_asn1_set_name (p5, p4->name);
- tlen = strlen (p4->value);
+ tlen = _asn1_strlen (p4->value);
if (tlen > 0)
_asn1_set_value (p5, p4->value, tlen + 1);
if (p2 == p)
{
_asn1_str_cpy (name2, sizeof (name2), name_root);
_asn1_str_cat (name2, sizeof (name2), ".");
- _asn1_str_cat (name2, sizeof (name2), p2->value);
+ _asn1_str_cat (name2, sizeof (name2), (char *) p2->value);
p3 = asn1_find_node (node, name2);
if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) ||
!(p3->type & CONST_ASSIGN))
{
if (name2[0])
_asn1_str_cat (name2, sizeof (name2), ".");
- _asn1_str_cat (name2, sizeof (name2), p4->value);
+ _asn1_str_cat (name2, sizeof (name2),
+ (char *) p4->value);
}
p4 = p4->right;
}
{
_asn1_str_cpy (name2, sizeof (name2), node->name);
_asn1_str_cat (name2, sizeof (name2), ".");
- _asn1_str_cat (name2, sizeof (name2), p->value);
+ _asn1_str_cat (name2, sizeof (name2), (char *) p->value);
p2 = asn1_find_node (node, name2);
if (p2 == NULL)
{
- strcpy (_asn1_identifierMissing, p->value);
+ _asn1_strcpy (_asn1_identifierMissing, p->value);
return ASN1_IDENTIFIER_NOT_FOUND;
}
}
{
_asn1_str_cpy (name2, sizeof (name2), node->name);
_asn1_str_cat (name2, sizeof (name2), ".");
- _asn1_str_cat (name2, sizeof (name2), p2->value);
- strcpy (_asn1_identifierMissing, p2->value);
+ _asn1_str_cat (name2, sizeof (name2), (char *) p2->value);
+ _asn1_strcpy (_asn1_identifierMissing, p2->value);
p2 = asn1_find_node (node, name2);
if (!p2 || (type_field (p2->type) != TYPE_OBJECT_ID) ||
!(p2->type & CONST_ASSIGN))
{
_asn1_str_cpy (name2, sizeof (name2), node->name);
_asn1_str_cat (name2, sizeof (name2), ".");
- _asn1_str_cat (name2, sizeof (name2), p2->value);
- strcpy (_asn1_identifierMissing, p2->value);
+ _asn1_str_cat (name2, sizeof (name2), (char *) p2->value);
+ _asn1_strcpy (_asn1_identifierMissing, p2->value);
p2 = asn1_find_node (node, name2);
if (!p2 || (type_field (p2->type) != TYPE_OBJECT_ID) ||
!(p2->type & CONST_ASSIGN))
if (type_field (p3->type) == TYPE_TAG)
{
p4 = _asn1_add_node_only (p3->type);
- tlen = strlen (p3->value);
+ tlen = _asn1_strlen (p3->value);
if (tlen > 0)
_asn1_set_value (p4, p3->value, tlen + 1);
_asn1_set_right (p4, p2->down);
{
_asn1_str_cpy (name2, sizeof (name2), root->name);
_asn1_str_cat (name2, sizeof (name2), ".");
- _asn1_str_cat (name2, sizeof (name2), p->value);
+ _asn1_str_cat (name2, sizeof (name2), (char *) p->value);
p2 = _asn1_copy_structure2 (root, name2);
if (p2 == NULL)
{
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) $(CFLAG_VISIBILITY)
AM_CPPFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I../gl
AM_LDFLAGS = -no-install
{
errstr = asn1_strerror (ec);
asn1_perror (ec);
-#ifndef ASN1_DISABLE_DEPRECATED
- errstr = libtasn1_strerror (ec);
- libtasn1_perror (ec);
-#endif
ec++;
}
while (errstr);
if (result != ASN1_SUCCESS)
{
asn1_perror (result);
- printf ("Cannot decode BER data (size %d)\n", size);
+ printf ("Cannot decode BER data (size %ld)\n", size);
exit (1);
}
typedef struct
{
int lineNumber;
- char *line;
+ const char *line;
int errorNumber;
- char *errorDescription;
+ const char *errorDescription;
} test_type;
-char *fileCorrectName;
+const char *fileCorrectName;
char fileErroredName[] = "Test_parser_ERROR.asn";
#define _FILE_ "Test_parser_ERROR.asn"
{0}
};
-int
+static int
readLine (FILE * file, char *line)
{
int c;
return c;
}
-
-void
-createFile (int lineNumber, char *line)
+static void
+createFile (int lineNumber, const char *line)
{
FILE *fileIn, *fileOut;
char lineRead[1024];
struct tv
{
- size_t bitlen;
+ int bitlen;
const char *bitstr;
- size_t derlen;
+ int derlen;
const char *der;
};
{
/* Encode */
- asn1_bit_der (tv[i].bitstr, tv[i].bitlen, der, &der_len);
+ asn1_bit_der ((const unsigned char *) tv[i].bitstr, tv[i].bitlen,
+ der, &der_len);
#if 0
{
if (der_len != tv[i].derlen
|| memcmp (der, tv[i].der, der_len) != 0)
{
- fprintf (stderr, "asn1_bit_der iter %d\n", i);
+ fprintf (stderr, "asn1_bit_der iter %ld\n", i);
return 1;
}
if (result != ASN1_SUCCESS || ret_len != tv[i].derlen
|| bit_len != tv[i].bitlen)
{
- fprintf (stderr, "asn1_get_bit_der iter %d\n", i);
+ fprintf (stderr, "asn1_get_bit_der iter %ld\n", i);
return 1;
}
}
{
int action;
const char *par1;
- const unsigned char *par2;
+ const char *par2;
int par3;
int errorNumber;
} test_type;
case ACT_READ_BIT:
if (test->action == ACT_READ_BIT)
{
- if ((valueLen - (valueLen / 8.0)) == 0)
+ if (valueLen % 8 == 0)
tag = valueLen / 8;
else
tag = (valueLen / 8) + 1;
- if ((test->par3 - (test->par3 / 8.0)) == 0)
+ if (test->par3 % 8 == 0)
class = test->par3 / 8;
else
class = (test->par3 / 8) + 1;
}
for (k = 0; k < class; k++)
- if (test->par2[k] != value[k])
+ if ((unsigned char) test->par2[k] != value[k])
{
k = -1;
break;