if ((buf = (char *)OPENSSL_malloc(inl + 1)) == NULL) {
return (0);
}
- strncpy(buf, in, inl);
- buf[inl] = '\0';
-
+ strlcpy(buf, in, inl + 1);
i = 0;
while (strncmp(buf, mapping[i].str, mapping[i].strl) != 0)
i++;
char *src = strerror(i);
if (src != NULL)
{
- strncpy(*dest, src, sizeof *dest);
- (*dest)[sizeof *dest - 1] = '\0';
+ strlcpy(*dest, src, sizeof *dest);
str->string = *dest;
}
}
prompt_string[0]='\0';
else
{
- strncpy(prompt_string,prompt,79);
- prompt_string[79]='\0';
+ strlcpy(prompt_string,prompt,sizeof(prompt_string));
}
}
int i;
unsigned int length = 0;
char *result = NULL;
- char *p;
/* Determine length first. */
for (i = 0; i < sk_ASN1_UTF8STRING_num(text); ++i)
return NULL;
}
/* Concatenate the descriptions. */
- for (i = 0, p = result; i < sk_ASN1_UTF8STRING_num(text); ++i)
+ result[0] = '\0';
+ for (i = 0; i < sk_ASN1_UTF8STRING_num(text); ++i)
{
ASN1_UTF8STRING *current = sk_ASN1_UTF8STRING_value(text, i);
- length = ASN1_STRING_length(current);
- if (i > 0) *p++ = '/';
- strncpy(p, (const char *)ASN1_STRING_data(current), length);
- p += length;
+ if (i > 0)
+ strlcat(result, "/", length);
+ strlcat(result, ASN1_STRING_data(current), length);
}
- /* We do have space for this, too. */
- *p = '\0';
-
return result;
}
return 0;
ent->dir_type = type;
ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
- ent->dir = OPENSSL_malloc((unsigned int)len + 1);
+ ent->dir = strdup(ss);
if (!ent->dir || !ent->hashes) {
by_dir_entry_free(ent);
return 0;
}
- strncpy(ent->dir, ss,(unsigned int)len);
- ent->dir[len] = '\0';
if (!sk_BY_DIR_ENTRY_push(ctx->dirs, ent)) {
by_dir_entry_free(ent);
return 0;
buf=b->data;
OPENSSL_free(b);
}
- strncpy(buf,"NO X509_NAME",len);
- buf[len-1]='\0';
+ strlcpy(buf,"NO X509_NAME",len);
return buf;
}
return 0;
objlen = p - value;
objtmp = OPENSSL_malloc(objlen + 1);
- strncpy(objtmp, value, objlen);
- objtmp[objlen] = 0;
- gen->d.otherName->type_id = OBJ_txt2obj(objtmp, 0);
- OPENSSL_free(objtmp);
+ if (objtmp) {
+ strlcpy(objtmp, value, objlen + 1);
+ gen->d.otherName->type_id = OBJ_txt2obj(objtmp, 0);
+ OPENSSL_free(objtmp);
+ } else
+ gen->d.otherName->type_id = NULL;
if (!gen->d.otherName->type_id)
return 0;
return 1;
X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,ERR_R_MALLOC_FAILURE);
goto err;
}
- strncpy(objtmp, cnf->name, objlen);
- objtmp[objlen] = 0;
+ strlcpy(objtmp, cnf->name, objlen + 1);
acc->method = OBJ_txt2obj(objtmp, 0);
if(!acc->method) {
X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,X509V3_R_BAD_OBJECT);
if ((buf = (char *)OPENSSL_malloc(inl + 1)) == NULL) {
return (0);
}
- strncpy(buf, in, inl);
- buf[inl] = '\0';
-
+ strlcpy(buf, in, inl + 1);
i = 0;
while (strncmp(buf, mapping[i].str, mapping[i].strl) != 0)
i++;
char *src = strerror(i);
if (src != NULL)
{
- strncpy(*dest, src, sizeof *dest);
- (*dest)[sizeof *dest - 1] = '\0';
+ strlcpy(*dest, src, sizeof *dest);
str->string = *dest;
}
}
prompt_string[0]='\0';
else
{
- strncpy(prompt_string,prompt,79);
- prompt_string[79]='\0';
+ strlcpy(prompt_string,prompt,sizeof(prompt_string));
}
}
int i;
unsigned int length = 0;
char *result = NULL;
- char *p;
/* Determine length first. */
for (i = 0; i < sk_ASN1_UTF8STRING_num(text); ++i)
return NULL;
}
/* Concatenate the descriptions. */
- for (i = 0, p = result; i < sk_ASN1_UTF8STRING_num(text); ++i)
+ result[0] = '\0';
+ for (i = 0; i < sk_ASN1_UTF8STRING_num(text); ++i)
{
ASN1_UTF8STRING *current = sk_ASN1_UTF8STRING_value(text, i);
- length = ASN1_STRING_length(current);
- if (i > 0) *p++ = '/';
- strncpy(p, (const char *)ASN1_STRING_data(current), length);
- p += length;
+ if (i > 0)
+ strlcat(result, "/", length);
+ strlcat(result, ASN1_STRING_data(current), length);
}
- /* We do have space for this, too. */
- *p = '\0';
-
return result;
}
return 0;
ent->dir_type = type;
ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
- ent->dir = OPENSSL_malloc((unsigned int)len + 1);
+ ent->dir = strdup(ss);
if (!ent->dir || !ent->hashes) {
by_dir_entry_free(ent);
return 0;
}
- strncpy(ent->dir, ss,(unsigned int)len);
- ent->dir[len] = '\0';
if (!sk_BY_DIR_ENTRY_push(ctx->dirs, ent)) {
by_dir_entry_free(ent);
return 0;
buf=b->data;
OPENSSL_free(b);
}
- strncpy(buf,"NO X509_NAME",len);
- buf[len-1]='\0';
+ strlcpy(buf,"NO X509_NAME",len);
return buf;
}
return 0;
objlen = p - value;
objtmp = OPENSSL_malloc(objlen + 1);
- strncpy(objtmp, value, objlen);
- objtmp[objlen] = 0;
- gen->d.otherName->type_id = OBJ_txt2obj(objtmp, 0);
- OPENSSL_free(objtmp);
+ if (objtmp) {
+ strlcpy(objtmp, value, objlen + 1);
+ gen->d.otherName->type_id = OBJ_txt2obj(objtmp, 0);
+ OPENSSL_free(objtmp);
+ } else
+ gen->d.otherName->type_id = NULL;
if (!gen->d.otherName->type_id)
return 0;
return 1;
X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,ERR_R_MALLOC_FAILURE);
goto err;
}
- strncpy(objtmp, cnf->name, objlen);
- objtmp[objlen] = 0;
+ strlcpy(objtmp, cnf->name, objlen + 1);
acc->method = OBJ_txt2obj(objtmp, 0);
if(!acc->method) {
X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,X509V3_R_BAD_OBJECT);
+++ /dev/null
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <openssl/e_os2.h>
-#include <openssl/buffer.h>
-#include <openssl/crypto.h>
-
-int main(int argc, char *argv[])
- {
- char *p, *q = 0, *program;
-
- p = strrchr(argv[0], '/');
- if (!p) p = strrchr(argv[0], '\\');
-#ifdef OPENSSL_SYS_VMS
- if (!p) p = strrchr(argv[0], ']');
- if (p) q = strrchr(p, '>');
- if (q) p = q;
- if (!p) p = strrchr(argv[0], ':');
- q = 0;
-#endif
- if (p) p++;
- if (!p) p = argv[0];
- if (p) q = strchr(p, '.');
- if (p && !q) q = p + strlen(p);
-
- if (!p)
- program = BUF_strdup("(unknown)");
- else
- {
- program = OPENSSL_malloc((q - p) + 1);
- strncpy(program, p, q - p);
- program[q - p] = '\0';
- }
-
- for(p = program; *p; p++)
- if (islower((unsigned char)(*p)))
- *p = toupper((unsigned char)(*p));
-
- q = strstr(program, "TEST");
- if (q > p && q[-1] == '_') q--;
- *q = '\0';
-
- printf("No %s support\n", program);
-
- OPENSSL_free(program);
- return(0);
- }
+++ /dev/null
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <openssl/e_os2.h>
-#include <openssl/buffer.h>
-#include <openssl/crypto.h>
-
-int main(int argc, char *argv[])
- {
- char *p, *q = 0, *program;
-
- p = strrchr(argv[0], '/');
- if (!p) p = strrchr(argv[0], '\\');
-#ifdef OPENSSL_SYS_VMS
- if (!p) p = strrchr(argv[0], ']');
- if (p) q = strrchr(p, '>');
- if (q) p = q;
- if (!p) p = strrchr(argv[0], ':');
- q = 0;
-#endif
- if (p) p++;
- if (!p) p = argv[0];
- if (p) q = strchr(p, '.');
- if (p && !q) q = p + strlen(p);
-
- if (!p)
- program = BUF_strdup("(unknown)");
- else
- {
- program = OPENSSL_malloc((q - p) + 1);
- strncpy(program, p, q - p);
- program[q - p] = '\0';
- }
-
- for(p = program; *p; p++)
- if (islower((unsigned char)(*p)))
- *p = toupper((unsigned char)(*p));
-
- q = strstr(program, "TEST");
- if (q > p && q[-1] == '_') q--;
- *q = '\0';
-
- printf("No %s support\n", program);
-
- OPENSSL_free(program);
- return(0);
- }