[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Check for errors reading the assignment file in asn1Coding.
From: |
Ivan Shmakov |
Subject: |
[PATCH] Check for errors reading the assignment file in asn1Coding. |
Date: |
Fri, 09 Nov 2012 14:56:38 +0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
Please consider the following patch.
Check for errors reading the assignment file in asn1Coding.
src/asn1Coding.c: Check the value returned by readAssignment ()
to be either ASSIGNMENT_SUCCESS or ASSIGNMENT_EOF.
Currently, the return value of readAssignment () is only
compared to ASSIGNMENT_SUCCESS; ASSIGNMENT_ERROR is treated
identically to ASSIGNMENT_EOF. Cf.:
$ cat < asn1
Example DEFINITIONS EXPLICIT TAGS ::=
BEGIN
Foo ::= OCTET STRING
END
$ asn1Coding-new -o /dev/null asn1 <(printf %s\\n 'x Example.Foo' "''"))
Parse: done.
var=x, value=Example.Foo
asn1Coding: error reading assignment file
$ asn1Coding-old -o /dev/null asn1 <(printf %s\\n 'x Example.Foo' "''"))
Parse: done.
var=x, value=Example.Foo
name:NULL type:OCT_STR
Coding: VALUE_NOT_FOUND
asn1Coding: :: value of element 'ROOT' not found
$
(Though perhaps the code should discern syntax errors from I/O
ones, and report the former as such.)
Two more deficiencies of the reading code are:
• the input is read in /tokens/, not /lines/, thus the following
are equivalent (and there's no way to specify an empty string
or a string with a blank as the value, etc.):
x Example.Foo
'' bar
x
Example.Foo ''
bar
x Example.Foo '' bar
• the code uses static buffers (varName[], value[]), but nowhere
reading is limited to their respective sizes.
I hope to provide a patch replacing fixing these issues (via
replacing fscanf () with fgets () and strsep ()) shortly.
--
FSF associate member #7257
txtg8asot9ODB.txt
Description: Text Data
- [PATCH] Check for errors reading the assignment file in asn1Coding.,
Ivan Shmakov <=