projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added missing source.
[yaz-moved-to-github.git]
/
src
/
pquery.c
diff --git
a/src/pquery.c
b/src/pquery.c
index
9dbba8b
..
da12e21
100644
(file)
--- a/
src/pquery.c
+++ b/
src/pquery.c
@@
-1,8
+1,8
@@
/*
/*
- * Copyright (C) 1995-2005, Index Data ApS
+ * Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
* See the file LICENSE for details.
*
- * $Id: pquery.c,v 1.6 2005-06-25 15:46:04 adam Exp $
+ * $Id: pquery.c,v 1.9 2007-01-03 08:42:15 adam Exp $
*/
/**
* \file pquery.c
*/
/**
* \file pquery.c
@@
-194,6
+194,7
@@
static int p_query_parse_attr(struct yaz_pqf_parser *li, ODR o,
char **attr_clist, oid_value *attr_set)
{
const char *cp;
char **attr_clist, oid_value *attr_set)
{
const char *cp;
+
if (!(cp = strchr (li->lex_buf, '=')) ||
(size_t) (cp-li->lex_buf) > li->lex_len)
{
if (!(cp = strchr (li->lex_buf, '=')) ||
(size_t) (cp-li->lex_buf) > li->lex_len)
{
@@
-221,8
+222,13
@@
static int p_query_parse_attr(struct yaz_pqf_parser *li, ODR o,
else
attr_set[num_attr] = VAL_NONE;
}
else
attr_set[num_attr] = VAL_NONE;
}
+ if (*li->lex_buf < '0' || *li->lex_buf > '9')
+ {
+ li->error = YAZ_PQF_ERROR_BAD_INTEGER;
+ return 0;
+ }
attr_list[2*num_attr] = atoi(li->lex_buf);
attr_list[2*num_attr] = atoi(li->lex_buf);
- cp++;
+ cp++;
if (*cp >= '0' && *cp <= '9')
{
attr_list[2*num_attr+1] = atoi (cp);
if (*cp >= '0' && *cp <= '9')
{
attr_list[2*num_attr+1] = atoi (cp);
@@
-403,29
+409,54
@@
static Z_ProximityOperator *rpn_proximity (struct yaz_pqf_parser *li, ODR o)
p->exclusion = odr_intdup (o, 1);
else if (*li->lex_buf == '0')
p->exclusion = odr_intdup (o, 0);
p->exclusion = odr_intdup (o, 1);
else if (*li->lex_buf == '0')
p->exclusion = odr_intdup (o, 0);
- else
+ else if (*li->lex_buf == 'v' || *li->lex_buf == 'n')
p->exclusion = NULL;
p->exclusion = NULL;
+ else
+ {
+ li->error = YAZ_PQF_ERROR_PROXIMITY;
+ return NULL;
+ }
if (!lex (li))
{
li->error = YAZ_PQF_ERROR_MISSING;
return NULL;
}
if (!lex (li))
{
li->error = YAZ_PQF_ERROR_MISSING;
return NULL;
}
- p->distance = odr_intdup (o, atoi(li->lex_buf));
+ if (*li->lex_buf >= '0' && *li->lex_buf <= '9')
+ p->distance = odr_intdup (o, atoi (li->lex_buf));
+ else
+ {
+ li->error = YAZ_PQF_ERROR_BAD_INTEGER;
+ return NULL;
+ }
if (!lex (li))
{
li->error = YAZ_PQF_ERROR_MISSING;
return NULL;
}
if (!lex (li))
{
li->error = YAZ_PQF_ERROR_MISSING;
return NULL;
}
- p->ordered = odr_intdup (o, atoi (li->lex_buf));
+ if (*li->lex_buf == '1')
+ p->ordered = odr_intdup (o, 1);
+ else if (*li->lex_buf == '0')
+ p->ordered = odr_intdup (o, 0);
+ else
+ {
+ li->error = YAZ_PQF_ERROR_PROXIMITY;
+ return NULL;
+ }
if (!lex (li))
{
li->error = YAZ_PQF_ERROR_MISSING;
return NULL;
}
if (!lex (li))
{
li->error = YAZ_PQF_ERROR_MISSING;
return NULL;
}
- p->relationType = odr_intdup (o, atoi (li->lex_buf));
+ if (*li->lex_buf >= '0' && *li->lex_buf <= '9')
+ p->relationType = odr_intdup (o, atoi (li->lex_buf));
+ else
+ {
+ li->error = YAZ_PQF_ERROR_BAD_INTEGER;
+ return NULL;
+ }
if (!lex (li))
{
if (!lex (li))
{
@@
-439,12
+470,25
@@
static Z_ProximityOperator *rpn_proximity (struct yaz_pqf_parser *li, ODR o)
else
p->which = atoi (li->lex_buf);
else
p->which = atoi (li->lex_buf);
+ if (p->which != Z_ProximityOperator_known
+ && p->which != Z_ProximityOperator_private)
+ {
+ li->error = YAZ_PQF_ERROR_PROXIMITY;
+ return NULL;
+ }
+
if (!lex (li))
{
li->error = YAZ_PQF_ERROR_MISSING;
return NULL;
}
if (!lex (li))
{
li->error = YAZ_PQF_ERROR_MISSING;
return NULL;
}
- p->u.known = odr_intdup (o, atoi(li->lex_buf));
+ if (*li->lex_buf >= '0' && *li->lex_buf <= '9')
+ p->u.known = odr_intdup (o, atoi(li->lex_buf));
+ else
+ {
+ li->error = YAZ_PQF_ERROR_BAD_INTEGER;
+ return NULL;
+ }
return p;
}
return p;
}
@@
-463,11
+507,11
@@
static Z_Complex *rpn_complex (struct yaz_pqf_parser *li, ODR o, oid_proto proto
{
case 'a':
zo->which = Z_Operator_and;
{
case 'a':
zo->which = Z_Operator_and;
- zo->u.and_not = odr_nullval();
+ zo->u.op_and = odr_nullval();
break;
case 'o':
zo->which = Z_Operator_or;
break;
case 'o':
zo->which = Z_Operator_or;
- zo->u.and_not = odr_nullval();
+ zo->u.op_or = odr_nullval();
break;
case 'n':
zo->which = Z_Operator_and_not;
break;
case 'n':
zo->which = Z_Operator_and_not;
@@
-800,6
+844,10
@@
int yaz_pqf_error (YAZ_PQF_Parser p, const char **msg, size_t *off)
*msg = "bad attribute specification"; break;
case YAZ_PQF_ERROR_INTERNAL:
*msg = "internal error"; break;
*msg = "bad attribute specification"; break;
case YAZ_PQF_ERROR_INTERNAL:
*msg = "internal error"; break;
+ case YAZ_PQF_ERROR_PROXIMITY:
+ *msg = "proximity error"; break;
+ case YAZ_PQF_ERROR_BAD_INTEGER:
+ *msg = "bad integer"; break;
default:
*msg = "unknown error"; break;
}
default:
*msg = "unknown error"; break;
}