Giter Club home page Giter Club logo

dotconf's Introduction

dot.conf v1.4

This file lists changes that break backward compatibility with previous
versions.  Please see the files in the doc directory of the distribution for
full details.

For examples of how to use this library, see the examples directory.

Changes after 1.0.13:

- dotconf_register_options now has a return type.  This function can now
  indicate success or failure.

  - To support the float argument for a config option, the data member of
    struct command_t gained the dvalue member.

This is free software licensed with the GNU Lesser General Public License 2.1.

I would like to thank Lukas Schroeder for authoring this project originally.
His address is listed in the Authors file if you need to contact him.
However, current questions about the project should be directed to me since I
am the current maintainer.

William Hubbs <[email protected]>


dotconf's People

Contributors

addisoncrump avatar hacker avatar williamh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dotconf's Issues

Code causes some warnings under -Wall -Wextra

When building dotconf under -Wall -Wextra, there are some warnings caused by dotconf.h:

/Users/sjors/Projecten/dazeus/dotconfbug/main.cpp:10:2: warning: missing field 'context' initializer [-Wmissing-field-initializers]
        LAST_OPTION
        ^
/Users/sjors/Projecten/dazeus/dotconfbug/dotconf/src/dotconf.h:42:49: note: expanded from macro 'LAST_OPTION'
#define LAST_OPTION                                             { "", 0, NULL, NULL    }
                                                                                       ^
/Users/sjors/Projecten/dazeus/dotconfbug/main.cpp:13:1: warning: unused parameter 'configfile' [-Wunused-parameter]
FUNC_ERRORHANDLER(error_handler) {
^
/Users/sjors/Projecten/dazeus/dotconfbug/dotconf/src/dotconf.h:47:59: note: expanded from macro 'FUNC_ERRORHANDLER'
#define FUNC_ERRORHANDLER(_name) int _name(configfile_t * configfile,             \
                                                          ^
/Users/sjors/Projecten/dazeus/dotconfbug/main.cpp:13:1: warning: unused parameter 'type' [-Wunused-parameter]
FUNC_ERRORHANDLER(error_handler) {
^
/Users/sjors/Projecten/dazeus/dotconfbug/dotconf/src/dotconf.h:48:16: note: expanded from macro 'FUNC_ERRORHANDLER'
                                                                                        int type, long dc_errno, const char *msg)
                                                                                            ^
/Users/sjors/Projecten/dazeus/dotconfbug/main.cpp:13:1: warning: unused parameter 'dc_errno' [-Wunused-parameter]
FUNC_ERRORHANDLER(error_handler) {
^
/Users/sjors/Projecten/dazeus/dotconfbug/dotconf/src/dotconf.h:48:27: note: expanded from macro 'FUNC_ERRORHANDLER'
                                                                                        int type, long dc_errno, const char *msg)
                                                                                                       ^
/Users/sjors/Projecten/dazeus/dotconfbug/main.cpp:13:1: warning: unused parameter 'msg' [-Wunused-parameter]
FUNC_ERRORHANDLER(error_handler) {
^
/Users/sjors/Projecten/dazeus/dotconfbug/dotconf/src/dotconf.h:48:49: note: expanded from macro 'FUNC_ERRORHANDLER'
                                                                                        int type, long dc_errno, const char *msg)
                                                                                                                             ^
/Users/sjors/Projecten/dazeus/dotconfbug/main.cpp:35:8: warning: unused parameter 'ctx' [-Wunused-parameter]
static DOTCONF_CB(option) {
       ^
/Users/sjors/Projecten/dazeus/dotconfbug/dotconf/src/dotconf.h:46:62: note: expanded from macro 'DOTCONF_CB'
                                                  context_t *ctx)
                                                             ^
6 warnings generated.

The main.cpp file is listed in #1 (first comment).

There are some other warnings in dotconf.c itself under both -Wall and -Wall -Wextra, that might need to be looked at/fixed too.

Errors through "Include" are not relayed

When a parsing error is introduced in a DOTCONF_CB function by returning a non-NULL charptr, dotconf_command_loop() is supposed to return 0 indicating failure to parse. This works fine for the main configuration file, but not if errors are found in included configuration files. I will attach a test case shortly, where the following configuration file fails as expected:

# error.conf
Error 1

The following file succeeds as expected:

# ok.conf
Error 0

And the following file succeeds unexpectedly, while it does invoke the error handler:

# include_error.conf
Include "error.conf"

No support for empty string options?

In speech dispatcher, we use string options which can have an empty value, which we write "". It seems that dotconf doesn't support it:

GenericPunctNone ""

yields to

Missing argument to option 'GenericPunctNone'

Invalid read / SIGSEGV

Input for examples/simple:

00000000  45 78 61 6d 70 6c 65 4c  69 73 74 20 20 20 20 20  |ExampleList     |
00000010  20 20 27 22 6c 69 6e 65  31 27 5c 0a 09 6c 69 6e  |  '"line1'\..lin|
00000020  65 32 73 6b 64 66 6a 0a  0a 45 78 61 6d 70 6c 65  |e2skdfj..Example|
00000030  53 74 72 20 20 20 3c 3c  74 65 73 74 0a 6c 69 6e  |Str   <<test.lin|
00000040  65 20 31 0a 20 32 0a 74  65 73 74 0a 0a 49 6e 63  |e 1. 2.test..Inc|
00000050  6c 75 64 65 00 69 6e 63  6c 75 64 65 64 2e 63 6f  |lude.included.co|
00000060  6e 66 0a 0a                                       |nf..|
00000064

How to reproduce:
./simple <input>

Valgrind output:

valgrind ./simple <input> --leak-check=full
==10333== Memcheck, a memory error detector
==10333== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==10333== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==10333== Command: ./simple <input> --leak-check=full
==10333== 
crash:2: ExampleList: [  (0) "line1  (1) line2skdfj  ]
crash:7: ExampleStr: [line 1
 2]
crash:9: Missing argument to option 'Include'
==10333== Invalid read of size 1
==10333==    at 0x407F77: dotconf_cb_include (dotconf.c:1461)
==10333==    by 0x40451C: dotconf_invoke_command (dotconf.c:369)
==10333==    by 0x40451C: dotconf_handle_command (dotconf.c:706)
==10333==    by 0x404888: dotconf_command_loop (dotconf.c:745)
==10333==    by 0x401713: main (simple.c:25)
==10333==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==10333== 
==10333== 
==10333== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==10333==  Access not within mapped region at address 0x0
==10333==    at 0x407F77: dotconf_cb_include (dotconf.c:1461)
==10333==    by 0x40451C: dotconf_invoke_command (dotconf.c:369)
==10333==    by 0x40451C: dotconf_handle_command (dotconf.c:706)
==10333==    by 0x404888: dotconf_command_loop (dotconf.c:745)
==10333==    by 0x401713: main (simple.c:25)
==10333==  If you believe this happened as a result of a stack
==10333==  overflow in your program's main thread (unlikely but
==10333==  possible), you can try to increase the size of the
==10333==  main thread stack using the --main-stacksize= flag.
==10333==  The main thread stack size used in this run was 8388608.
==10333== 
==10333== HEAP SUMMARY:
==10333==     in use at exit: 1,134 bytes in 6 blocks
==10333==   total heap usage: 16 allocs, 10 frees, 6,656 bytes allocated
==10333== 
==10333== LEAK SUMMARY:
==10333==    definitely lost: 0 bytes in 0 blocks
==10333==    indirectly lost: 0 bytes in 0 blocks
==10333==      possibly lost: 0 bytes in 0 blocks
==10333==    still reachable: 1,134 bytes in 6 blocks
==10333==         suppressed: 0 bytes in 0 blocks
==10333== Rerun with --leak-check=full to see details of leaked memory
==10333== 
==10333== For counts of detected and suppressed errors, rerun with: -v
==10333== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

found with afl-fuzz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.