]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
certtool: eliminate maximum limit in fields read with READ_MULTI_LINE_TOKENIZED()
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Thu, 26 Jul 2018 08:56:25 +0000 (10:56 +0200)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Thu, 26 Jul 2018 08:57:03 +0000 (10:57 +0200)
This allows to generate a certificate with an extension of arbitrary size.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
src/certtool-cfg.c

index f13dabfa826f4659de858ca45c2ef8fb1b3fc243..b2f4e9ce11a57ff7ec403c4a3d8519ba621ff001 100644 (file)
@@ -261,22 +261,15 @@ void cfg_init(void)
   val = optionGetValue(pov, name); \
   if (val != NULL && val->valType == OPARG_TYPE_STRING) \
   { \
-    char str[512]; \
-    char * p; \
-    size_t len; \
+    char *str; \
+    char *p; \
     if (s_name == NULL) { \
       i = 0; \
       s_name = malloc(sizeof(char*)*MAX_ENTRIES); \
       do { \
        if (val && strcmp(val->pzName, name)!=0) \
          continue; \
-       len = strlen(val->v.strVal); \
-       if (sizeof(str) > (unsigned)len) { \
-               strcpy(str, val->v.strVal); \
-       } else { \
-               memcpy(str, val->v.strVal, sizeof(str)-1); \
-               str[sizeof(str)-1] = 0; \
-       } \
+       str = strdup(val->v.strVal); \
        if ((p=strchr(str, ' ')) == NULL && (p=strchr(str, '\t')) == NULL) { \
          fprintf(stderr, "Error parsing %s\n", name); \
          exit(1); \
@@ -291,6 +284,7 @@ void cfg_init(void)
        } \
        s_name[i+1] = strdup(p); \
        i+=2; \
+       free(str); \
        if (i>=MAX_ENTRIES) \
          break; \
       } while((val = optionNextValue(pov, val)) != NULL); \