diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-05-27 06:29:15 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-05-27 06:29:15 +0000 |
commit | a0af75b22aae2af15d374b505e52fd4ff99ceb59 (patch) | |
tree | c34dd869c090e0e5f82255d331c547b9f64dee3c /lib/libkeynote/keynote.l | |
parent | be818a3515d18fe09837751641f46a73b71ca2fa (diff) |
snprintf and strlcpy cleanup; angelos ok
Diffstat (limited to 'lib/libkeynote/keynote.l')
-rw-r--r-- | lib/libkeynote/keynote.l | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/libkeynote/keynote.l b/lib/libkeynote/keynote.l index f5b9bdb656b..b3a3963eaa8 100644 --- a/lib/libkeynote/keynote.l +++ b/lib/libkeynote/keynote.l @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: keynote.l,v 1.13 2001/09/03 20:14:51 deraadt Exp $ */ +/* $OpenBSD: keynote.l,v 1.14 2002/05/27 06:29:14 deraadt Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu) * @@ -125,6 +125,7 @@ comment "#"[^\n]* <LOCALINIT>"=" return EQQ; <KEYPREDICATE>"," return COMMA; <ACTIONSTRING,KEYPREDICATE,SIGNERINIT,LOCALINIT>{variable} { + int len; if (keynote_exceptionflag || keynote_donteval) { @@ -132,15 +133,14 @@ comment "#"[^\n]* return VARIABLE; } - knlval.string = calloc(strlen(kntext) - + 1, - sizeof(char)); + len = strlen(kntext) + 1; + knlval.string = calloc(len, sizeof(char)); if (knlval.string == (char *) NULL) { keynote_errno = ERROR_MEMORY; return -1; } - strcpy(knlval.string, kntext); + strlcpy(knlval.string, kntext, len); if (keynote_lex_add(knlval.string, LEXTYPE_CHAR) == -1) @@ -155,6 +155,8 @@ comment "#"[^\n]* return FLOAT; } <KEYNOTEVERSION>{number} { + int len; + if (keynote_exceptionflag || keynote_donteval) { @@ -162,14 +164,14 @@ comment "#"[^\n]* return STRING; } - knlval.string = calloc(strlen(kntext) + 1, - sizeof(char)); + len = strlen(kntext) + 1; + knlval.string = calloc(len, sizeof(char)); if (knlval.string == (char *) NULL) { keynote_errno = ERROR_MEMORY; return -1; } - strcpy(knlval.string, kntext); + strlcpy(knlval.string, kntext, len); if (keynote_lex_add(knlval.string, LEXTYPE_CHAR) == -1) return -1; |