Code Monkey home page Code Monkey logo

emjson's Issues

Crashing input example (null pointer dereference), and other issues

I came across your library today, and after some poking around I discovered an input that causes the parser to deference a null pointer: {"":{. Complete example program:

#include "emJSON.h"
int main(void)
{
    char buf[] = "{\"\":{";
    json_t test = emJSON_init();
    json_parse(&test, buf);
}

After fixing, fuzzing may reveal additional crashing inputs. Other issues I noticed:

  • Compilation requires -DDEBUG due to an incorrectly-placed #endif
  • Unaligned memory accesses (to observe, compile and run with UBSan, -fsanitize=undefined)
  • Invalid signed shifts (to observe, compile and run with UBSan, -fsanitize=undefined)
  • Pointer arithmetic on void *, a GNU extension and not valid C99 (to observe, compile with -pedantic -std=c99)
  • Variadic macros that depend on a GNU extension, not valid in C99 (to observe, compile with -pedantic -std=c99)

I only point out the last two since the README says "written in C99."

Development progress

🚧 In progress.

Adding object type.

  • adding it in json.h : Done in PR #3
  • adding it in emJSON.h
  • adding parser for object type : Done in PR #5
  • handling buffer inside/outside of parent buffer

Adding null type (needed for adding object type)

  • adding it in json.h : Done in PR #3, #5
  • Serialize : Done in PR #5
  • adding it in emJSON.h
  • adding parser for null type
  • Proper handling

Others

  • Delete content size
  • Optimize
  • Automatic adjusting size
  • Compile option for architecture not supporting unaligned access (such as ARM by default)

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.