static void remove_space(char **pval)
{
- unsigned char *p = (unsigned char *)*pval;
+ unsigned char *p = (unsigned char *)*pval, *beginning;
while (isspace(*p))
p++;
- *pval = (char *)p;
+ *pval = (char *)(beginning = p);
p = p + strlen(*pval) - 1;
/* Remove trailing space */
- while (isspace(*p))
+ while (p >= beginning && isspace(*p))
*p-- = 0;
}
long len;
*buflen = 0;
+
+ /* Check for empty value */
if (!*value) {
/*
* Don't return NULL for zero length buffer.
*buflen = 0;
return 1;
}
+
+ /* Check for NULL literal */
+ if (strcmp(value, "NULL") == 0) {
+ *buf = NULL;
+ *buflen = 0;
+ return 1;
+ }
+
/* Check for string literal */
if (value[0] == '"') {
size_t vlen;
return 1;
}
+ /* Otherwise assume as hex literal and convert it to binary buffer */
*buf = OPENSSL_hexstr2buf(value, &len);
if (!*buf) {
fprintf(stderr, "Value=%s\n", value);
ERR_clear_error();
return 1;
}
+#ifndef OPENSSL_NO_EC
+ /*
+ * If EC support is enabled we should catch also EC_R_UNKNOWN_GROUP as an
+ * hint to an unsupported algorithm/curve (e.g. if binary EC support is
+ * disabled).
+ */
+ if (ERR_GET_LIB(err) == ERR_LIB_EC
+ && ERR_GET_REASON(err) == EC_R_UNKNOWN_GROUP) {
+ ERR_clear_error();
+ return 1;
+ }
+#endif /* OPENSSL_NO_EC */
return 0;
}
memset(&t, 0, sizeof(t));
t.start_line = -1;
- in = BIO_new_file(argv[1], "r");
+ in = BIO_new_file(argv[1], "rb");
if (in == NULL) {
fprintf(stderr, "Can't open %s for reading\n", argv[1]);
return 1;