summaryrefslogtreecommitdiffstats
path: root/crypto/heimdal/lib/com_err/parse.y
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/heimdal/lib/com_err/parse.y')
-rw-r--r--crypto/heimdal/lib/com_err/parse.y38
1 files changed, 22 insertions, 16 deletions
diff --git a/crypto/heimdal/lib/com_err/parse.y b/crypto/heimdal/lib/com_err/parse.y
index 82e99ff..3159313 100644
--- a/crypto/heimdal/lib/com_err/parse.y
+++ b/crypto/heimdal/lib/com_err/parse.y
@@ -35,7 +35,7 @@
#include "compile_et.h"
#include "lex.h"
-RCSID("$Id: parse.y,v 1.11 2000/06/22 00:42:52 assar Exp $");
+RCSID("$Id: parse.y 15426 2005-06-16 19:21:42Z lha $");
void yyerror (char *s);
static long name2number(const char *str);
@@ -77,16 +77,14 @@ id : ID STRING
et : ET STRING
{
- base = name2number($2);
- strncpy(name, $2, sizeof(name));
- name[sizeof(name) - 1] = '\0';
+ base_id = name2number($2);
+ strlcpy(name, $2, sizeof(name));
free($2);
}
| ET STRING STRING
{
- base = name2number($2);
- strncpy(name, $3, sizeof(name));
- name[sizeof(name) - 1] = '\0';
+ base_id = name2number($2);
+ strlcpy(name, $3, sizeof(name));
free($2);
free($3);
}
@@ -102,24 +100,32 @@ statement : INDEX NUMBER
}
| PREFIX STRING
{
- prefix = realloc(prefix, strlen($2) + 2);
- strcpy(prefix, $2);
- strcat(prefix, "_");
+ free(prefix);
+ asprintf (&prefix, "%s_", $2);
+ if (prefix == NULL)
+ errx(1, "malloc");
free($2);
}
| PREFIX
{
prefix = realloc(prefix, 1);
+ if (prefix == NULL)
+ errx(1, "malloc");
*prefix = '\0';
}
| EC STRING ',' STRING
{
struct error_code *ec = malloc(sizeof(*ec));
+
+ if (ec == NULL)
+ errx(1, "malloc");
ec->next = NULL;
ec->number = number;
if(prefix && *prefix != '\0') {
asprintf (&ec->name, "%s%s", prefix, $2);
+ if (ec->name == NULL)
+ errx(1, "malloc");
free($2);
} else
ec->name = $2;
@@ -139,7 +145,7 @@ static long
name2number(const char *str)
{
const char *p;
- long base = 0;
+ long num = 0;
const char *x = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz0123456789_";
if(strlen(str) > 4) {
@@ -152,12 +158,12 @@ name2number(const char *str)
yyerror("invalid character in table name");
return 0;
}
- base = (base << 6) + (q - x) + 1;
+ num = (num << 6) + (q - x) + 1;
}
- base <<= 8;
- if(base > 0x7fffffff)
- base = -(0xffffffff - base + 1);
- return base;
+ num <<= 8;
+ if(num > 0x7fffffff)
+ num = -(0xffffffff - num + 1);
+ return num;
}
void
OpenPOWER on IntegriCloud