Re: [PATCH 02/27] ASN.1: Copy string names to tokens in ASN.1 compiler [ver #7]
On Wed, 2015-08-05 at 19:26 +0100, David Howells wrote: > Mimi Zohar wrote: > > > This patch isn't applying properly against linux-security/next. The > > rest seem to be fine. > > Did you apply the asn1-fixes-20150805 first and patch 1? > > Note that the branch is based on security/next, with my asn1-fixes-20150805 > tag merged on top - so it *ought* to apply. Yes, that works. Thanks! Mimi -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 02/27] ASN.1: Copy string names to tokens in ASN.1 compiler [ver #7]
Mimi Zohar wrote: > This patch isn't applying properly against linux-security/next. The > rest seem to be fine. Did you apply the asn1-fixes-20150805 first and patch 1? Note that the branch is based on security/next, with my asn1-fixes-20150805 tag merged on top - so it *ought* to apply. David -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 02/27] ASN.1: Copy string names to tokens in ASN.1 compiler [ver #7]
Hi David, This patch isn't applying properly against linux-security/next. The rest seem to be fine. Mimi On Wed, 2015-08-05 at 14:43 +0100, David Howells wrote: > Copy string names to tokens in ASN.1 compiler rather than storing a pointer > into the source text. This means we don't have to use "%*.*s" all over the > place. > > Signed-off-by: David Howells > Reviewed-by: David Woodhouse > --- > > scripts/asn1_compiler.c | 155 > ++- > 1 file changed, 73 insertions(+), 82 deletions(-) > > diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c > index 6e4ba992a51f..e000f44e37b8 100644 > --- a/scripts/asn1_compiler.c > +++ b/scripts/asn1_compiler.c > @@ -294,8 +294,8 @@ static const char *const directives[NR__DIRECTIVES] = { > > struct action { > struct action *next; > + char*name; > unsigned char index; > - charname[]; > }; > > static struct action *action_list; > @@ -306,7 +306,7 @@ struct token { > enum token_type token_type : 8; > unsigned char size; > struct action *action; > - const char *value; > + char*content; > struct type *type; > }; > > @@ -328,11 +328,9 @@ static int directive_compare(const void *_key, const > void *_pdir) > dlen = strlen(dir); > clen = (dlen < token->size) ? dlen : token->size; > > - //debug("cmp(%*.*s,%s) = ", > - // (int)token->size, (int)token->size, token->value, > - // dir); > + //debug("cmp(%s,%s) = ", token->content, dir); > > - val = memcmp(token->value, dir, clen); > + val = memcmp(token->content, dir, clen); > if (val != 0) { > //debug("%d [cmp]\n", val); > return val; > @@ -352,7 +350,7 @@ static int directive_compare(const void *_key, const void > *_pdir) > static void tokenise(char *buffer, char *end) > { > struct token *tokens; > - char *line, *nl, *p, *q; > + char *line, *nl, *start, *p, *q; > unsigned tix, lineno; > > /* Assume we're going to have half as many tokens as we have > @@ -411,11 +409,11 @@ static void tokenise(char *buffer, char *end) > break; > > tokens[tix].line = lineno; > - tokens[tix].value = p; > + start = p; > > /* Handle string tokens */ > if (isalpha(*p)) { > - const char **dir; > + const char **dir, *start = p; > > /* Can be a directive, type name or element >* name. Find the end of the name. > @@ -426,10 +424,18 @@ static void tokenise(char *buffer, char *end) > tokens[tix].size = q - p; > p = q; > > + tokens[tix].content = malloc(tokens[tix].size + > 1); > + if (!tokens[tix].content) { > + perror(NULL); > + exit(1); > + } > + memcpy(tokens[tix].content, start, > tokens[tix].size); > + tokens[tix].content[tokens[tix].size] = 0; > + > /* If it begins with a lowercase letter then >* it's an element name >*/ > - if (islower(tokens[tix].value[0])) { > + if (islower(tokens[tix].content[0])) { > tokens[tix++].token_type = > TOKEN_ELEMENT_NAME; > continue; > } > @@ -458,6 +464,13 @@ static void tokenise(char *buffer, char *end) > q++; > tokens[tix].size = q - p; > p = q; > + tokens[tix].content = malloc(tokens[tix].size + > 1); > + if (!tokens[tix].content) { > + perror(NULL); > + exit(1); > + } > + memcpy(tokens[tix].content, start, > tokens[tix].size); > + tokens[tix].content[tokens[tix].size] = 0; > tokens[tix++].token_type = TOKEN_NUMBER; > continue; > } > @@ -466,6 +479,7 @@ static void tokenise(char *buffer, char *end) > if (memcmp(p, "::=", 3) == 0) { > p += 3; > tokens[tix].size = 3; > + tokens[tix].content = "::="; >
[PATCH 02/27] ASN.1: Copy string names to tokens in ASN.1 compiler [ver #7]
Copy string names to tokens in ASN.1 compiler rather than storing a pointer into the source text. This means we don't have to use "%*.*s" all over the place. Signed-off-by: David Howells Reviewed-by: David Woodhouse --- scripts/asn1_compiler.c | 155 ++- 1 file changed, 73 insertions(+), 82 deletions(-) diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c index 6e4ba992a51f..e000f44e37b8 100644 --- a/scripts/asn1_compiler.c +++ b/scripts/asn1_compiler.c @@ -294,8 +294,8 @@ static const char *const directives[NR__DIRECTIVES] = { struct action { struct action *next; + char*name; unsigned char index; - charname[]; }; static struct action *action_list; @@ -306,7 +306,7 @@ struct token { enum token_type token_type : 8; unsigned char size; struct action *action; - const char *value; + char*content; struct type *type; }; @@ -328,11 +328,9 @@ static int directive_compare(const void *_key, const void *_pdir) dlen = strlen(dir); clen = (dlen < token->size) ? dlen : token->size; - //debug("cmp(%*.*s,%s) = ", - // (int)token->size, (int)token->size, token->value, - // dir); + //debug("cmp(%s,%s) = ", token->content, dir); - val = memcmp(token->value, dir, clen); + val = memcmp(token->content, dir, clen); if (val != 0) { //debug("%d [cmp]\n", val); return val; @@ -352,7 +350,7 @@ static int directive_compare(const void *_key, const void *_pdir) static void tokenise(char *buffer, char *end) { struct token *tokens; - char *line, *nl, *p, *q; + char *line, *nl, *start, *p, *q; unsigned tix, lineno; /* Assume we're going to have half as many tokens as we have @@ -411,11 +409,11 @@ static void tokenise(char *buffer, char *end) break; tokens[tix].line = lineno; - tokens[tix].value = p; + start = p; /* Handle string tokens */ if (isalpha(*p)) { - const char **dir; + const char **dir, *start = p; /* Can be a directive, type name or element * name. Find the end of the name. @@ -426,10 +424,18 @@ static void tokenise(char *buffer, char *end) tokens[tix].size = q - p; p = q; + tokens[tix].content = malloc(tokens[tix].size + 1); + if (!tokens[tix].content) { + perror(NULL); + exit(1); + } + memcpy(tokens[tix].content, start, tokens[tix].size); + tokens[tix].content[tokens[tix].size] = 0; + /* If it begins with a lowercase letter then * it's an element name */ - if (islower(tokens[tix].value[0])) { + if (islower(tokens[tix].content[0])) { tokens[tix++].token_type = TOKEN_ELEMENT_NAME; continue; } @@ -458,6 +464,13 @@ static void tokenise(char *buffer, char *end) q++; tokens[tix].size = q - p; p = q; + tokens[tix].content = malloc(tokens[tix].size + 1); + if (!tokens[tix].content) { + perror(NULL); + exit(1); + } + memcpy(tokens[tix].content, start, tokens[tix].size); + tokens[tix].content[tokens[tix].size] = 0; tokens[tix++].token_type = TOKEN_NUMBER; continue; } @@ -466,6 +479,7 @@ static void tokenise(char *buffer, char *end) if (memcmp(p, "::=", 3) == 0) { p += 3; tokens[tix].size = 3; + tokens[tix].content = "::="; tokens[tix++].token_type = TOKEN_ASSIGNMENT; continue; } @@ -475,12 +489,14 @@ static void tokenise(char *buffer, char *end)