[Mplayer-cvslog] CVS: main cfgparser.c,1.8,1.9
Szabolcs Berecz
szabii at users.sourceforge.net
Mon Mar 19 22:06:58 CET 2001
Update of /cvsroot/mplayer/main
In directory usw-pr-cvs1:/tmp/cvs-serv8417
Modified Files:
cfgparser.c
Log Message:
include recursion check
Index: cfgparser.c
===================================================================
RCS file: /cvsroot/mplayer/main/cfgparser.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** cfgparser.c 2001/03/19 15:09:47 1.8
--- cfgparser.c 2001/03/19 21:06:56 1.9
***************
*** 20,23 ****
--- 20,25 ----
#define CONFIG_FILE 1
+ #define MAX_RECURSION_DEPTH 10
+
#ifdef DEBUG
#include <assert.h>
***************
*** 29,32 ****
--- 31,35 ----
static int nr_options; /* number of options in 'conf' */
static int parser_mode; /* COMMAND_LINE or CONFIG_FILE */
+ static int recursion_depth = 0;
static int init_conf(struct config *conf, int mode)
***************
*** 191,195 ****
goto err_missing_param;
if ((((cfg_func_param_t) config[i].p)(config + i, param)) < 0) {
- printf("parser function returned error:\n");
ret = ERR_FUNC_ERR;
goto out;
--- 194,197 ----
***************
*** 199,203 ****
case CONF_TYPE_FUNC:
if ((((cfg_func_t) config[i].p)(config + i)) < 0) {
- printf("parser function returned error:\n");
ret = ERR_FUNC_ERR;
goto out;
--- 201,204 ----
***************
*** 240,251 ****
assert(conffile != NULL);
#endif
printf("Reading config file: %s\n", conffile);
! if (init_conf(conf, CONFIG_FILE) == -1)
! return -1;
if ((line = (char *) malloc(MAX_LINE_LEN)) == NULL) {
perror("parse_config_file: can't get memory for 'line'");
! return -1;
}
--- 241,260 ----
assert(conffile != NULL);
#endif
+ if (++recursion_depth > MAX_RECURSION_DEPTH) {
+ printf("too deep 'include'. check your configfiles\n");
+ return -1;
+ }
+
printf("Reading config file: %s\n", conffile);
! if (init_conf(conf, CONFIG_FILE) == -1) {
! ret = -1;
! goto out;
! }
if ((line = (char *) malloc(MAX_LINE_LEN)) == NULL) {
perror("parse_config_file: can't get memory for 'line'");
! ret = -1;
! goto out;
}
***************
*** 253,257 ****
perror("parse_config_file: can't open filename");
free(line);
! return 0;
}
--- 262,267 ----
perror("parse_config_file: can't open filename");
free(line);
! ret = 0;
! goto out;
}
***************
*** 358,361 ****
--- 368,373 ----
free(line);
fclose(fp);
+ out:
+ --recursion_depth;
return ret;
}
_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog
More information about the MPlayer-cvslog
mailing list