projects
/
runtime.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'silc.1.1.branch' of silc repo
[runtime.git]
/
lib
/
silcutil
/
silcconfig.c
diff --git
a/lib/silcutil/silcconfig.c
b/lib/silcutil/silcconfig.c
index 0568bd42eb04ce8b0b458c3fa3c7db30866f1fb6..0a9a34644f79cff40f3c040bba26aa2e100fe3a2 100644
(file)
--- a/
lib/silcutil/silcconfig.c
+++ b/
lib/silcutil/silcconfig.c
@@
-26,6
+26,8
@@
#define SILC_CONFIG_DEBUG(fmt)
#endif
#define SILC_CONFIG_DEBUG(fmt)
#endif
+#define BUF_SIZE 255
+
/* this is the option struct and currently it is only used internally to
* the module and other structs. */
typedef struct SilcConfigOptionStruct {
/* this is the option struct and currently it is only used internally to
* the module and other structs. */
typedef struct SilcConfigOptionStruct {
@@
-111,11
+113,14
@@
static void my_skip_line(SilcConfigFile *file)
* a separator is any non alphanumeric character nor "_" or "-" */
static char *my_next_token(SilcConfigFile *file, char *to)
{
* a separator is any non alphanumeric character nor "_" or "-" */
static char *my_next_token(SilcConfigFile *file, char *to)
{
+ unsigned int count = 0;
register char *o;
my_trim_spaces(file);
o = file->p;
register char *o;
my_trim_spaces(file);
o = file->p;
- while (isalnum((int)*o) || (*o == '_') || (*o == '-'))
+ while ((isalnum((int)*o) || (*o == '_') || (*o == '-')) && count < BUF_SIZE) {
+ count++;
*to++ = *o++;
*to++ = *o++;
+ }
*to = '\0';
file->p = o;
return to;
*to = '\0';
file->p = o;
return to;
@@
-129,24
+134,30
@@
static char *my_get_string(SilcConfigFile *file, char *to)
my_trim_spaces(file);
o = file->p;
if (*o == '"') {
my_trim_spaces(file);
o = file->p;
if (*o == '"') {
- char *quot = strchr(++o, '"');
- int len = quot - o;
- if (!quot) { /* XXX FIXME: gotta do something here */
- printf("Bullshit, missing matching \"");
- exit(1);
+ unsigned int count = 0;
+ char *d = to;
+ while (count < BUF_SIZE) {
+ o++;
+ if (*o == '"') {
+ break;
+ }
+ if (*o == '\\') {
+ o++;
+ }
+ count++;
+ *d++ = *o;
}
}
- if (len <= 0)
- *to = '\0';
- else {
- strncpy(to, o, len);
- to[len] = '\0';
+ if (count >= BUF_SIZE) { /* XXX FIXME: gotta do something here */
+ fprintf(stderr, "Bullshit, missing matching \"");
+ exit(1);
}
}
+ *d = '\0';
/* update stream pointer */
/* update stream pointer */
- file->p = quot + 1;
- return to;
+ file->p = o + 1;
+ } else {
+ /* we don't need quote parsing, fall-back to token extractor */
+ my_next_token(file, to);
}
}
- /* we don't need quote parsing, fall-back to token extractor */
- my_next_token(file, to);
return to;
}
return to;
}
@@
-453,7
+464,7
@@
static int silc_config_main_internal(SilcConfigEntity ent)
/* loop throught statements */
while (1) {
/* loop throught statements */
while (1) {
- char buf[
255
];
+ char buf[
BUF_SIZE
];
SilcConfigOption *thisopt;
/* makes it pointing to the next interesting char */
SilcConfigOption *thisopt;
/* makes it pointing to the next interesting char */