[Redbutton-devel] SF.net SVN: redbutton: [424] redbutton-author/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2007-09-25 11:59:43
|
Revision: 424
http://redbutton.svn.sourceforge.net/redbutton/?rev=424&view=rev
Author: skilvington
Date: 2007-09-25 04:59:39 -0700 (Tue, 25 Sep 2007)
Log Message:
-----------
report line number if STRINGs or QPRINTABLEs are invalid
Modified Paths:
--------------
redbutton-author/trunk/TODO
redbutton-author/trunk/der_encode.c
Modified: redbutton-author/trunk/TODO
===================================================================
--- redbutton-author/trunk/TODO 2007-09-24 18:35:05 UTC (rev 423)
+++ redbutton-author/trunk/TODO 2007-09-25 11:59:39 UTC (rev 424)
@@ -7,9 +7,5 @@
---
-change fatal()'s to parse_error()'s in convert_STRING() et al.
-
----
-
clean up ccc.y
Modified: redbutton-author/trunk/der_encode.c
===================================================================
--- redbutton-author/trunk/der_encode.c 2007-09-24 18:35:05 UTC (rev 423)
+++ redbutton-author/trunk/der_encode.c 2007-09-25 11:59:39 UTC (rev 424)
@@ -127,6 +127,7 @@
{
const unsigned char *whole_str = str;
unsigned char *p;
+ bool err;
/* max size it could be */
*out = safe_malloc(strlen(str));
@@ -134,11 +135,13 @@
/* skip the initial " */
str ++;
p = *out;
- while(*str != '"')
+ err = false;
+ while(!err && *str != '"')
{
if(*str < 0x20 || *str > 0x7e)
{
- fatal("Invalid character (0x%02x) in STRING: %s", *str, whole_str);
+ parse_error("Invalid character (0x%02x) in STRING: %s", *str, whole_str);
+ err = true;
}
else if(*str != '\\')
{
@@ -160,17 +163,30 @@
}
else
{
- /* TODO: show the line number */
- fatal("Invalid escape sequence in STRING: %s", whole_str);
+ parse_error("Invalid escape sequence in STRING: %s", whole_str);
+ err = true;
}
}
/* check we got to the closing quote */
- if(*(str + 1) != '\0')
- fatal("Unquoted \" in STRING: %s", whole_str);
+ if(!err && *(str + 1) != '\0')
+ {
+ parse_error("Unquoted \" in STRING: %s", whole_str);
+ err = true;
+ }
- /* return the length (note: no \0 terminator) */
- *len = (p - *out);
+ if(!err)
+ {
+ /* return the length (note: no \0 terminator) */
+ *len = (p - *out);
+ }
+ else
+ {
+ /* clean up */
+ safe_free(*out);
+ *out = NULL;
+ *len = 0;
+ }
return;
}
@@ -187,6 +203,7 @@
{
const unsigned char *whole_str = str;
unsigned char *p;
+ bool err;
/* max size it could be */
*out = safe_malloc(strlen(str));
@@ -194,7 +211,8 @@
/* skip the initial ' */
str ++;
p = *out;
- while(*str != '\'')
+ err = false;
+ while(!err && *str != '\'')
{
if(*str != '=')
{
@@ -210,17 +228,30 @@
}
else
{
- /* TODO: show the line number */
- fatal("Invalid escape sequence in QPRINTABLE: %s", whole_str);
+ parse_error("Invalid escape sequence in QPRINTABLE: %s", whole_str);
+ err = true;
}
}
/* check we got to the closing quote */
- if(*(str + 1) != '\0')
- fatal("Unquoted ' in QPRINTABLE: %s", whole_str);
+ if(!err && *(str + 1) != '\0')
+ {
+ parse_error("Unquoted ' in QPRINTABLE: %s", whole_str);
+ err = true;
+ }
- /* return the length (note: no \0 terminator) */
- *len = (p - *out);
+ if(!err)
+ {
+ /* return the length (note: no \0 terminator) */
+ *len = (p - *out);
+ }
+ else
+ {
+ /* clean up */
+ safe_free(*out);
+ *out = NULL;
+ *len = 0;
+ }
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|