json-c/json-c — pull request #162 by commodo (2014-12-05 09:22:46+00:00)
Title: json_util: add directory check for POSIX distros

On a Linux based target (OpenWRT to be more explicit), a directory path
to json_object_from_file() returns a non-NULL object.

On WIN32 the docs say:
http://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx

EACCES
Tried to open a read-only file for writing, file's sharing mode does
not allow the specified operations, or the given path is a directory.

On Linux/Unix:
http://linux.die.net/man/2/open

EISDIR
pathname refers to a directory and the access requested involved
writing (that is, O_WRONLY or O_RDWR is set).

The quickest/easiest fix would be to change O_RDONLY to O_RDWR.

I feel it's safer to explicitly check on POSIX targets if the file
is a directory.

I would be fine with whatever approach, as long as it is reviewed
by the creator/maintainer.

Signed-off-by: Alexandru Ardelean