Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clsync api is unstable due to dependency on defines #141

Open
bircoph opened this issue May 24, 2015 · 0 comments
Open

clsync api is unstable due to dependency on defines #141

bircoph opened this issue May 24, 2015 · 0 comments
Assignees
Milestone

Comments

@bircoph
Copy link
Collaborator

bircoph commented May 24, 2015

I was testing clsync so handler and found that clsync API is unstable due to its dependence on defines.

E.g. when compiling helper module I found that ctx_p->watchdir contains "nolabel" instead of watchdir. This happend due to 1 element shift due to #ifdef CAPABILITIES_SUPPORT:

struct ctx {
...
#ifdef CAPABILITIES_SUPPORT
        __u32 caps;
#endif
...
        char *label;
        char *watchdir;
...
};

so handler was compiled without -DCAPABILITIES_SUPPORT while clsync had it enabled.

This is a serious security issue as it may lead to memory corruption easily.
We must find a way to guarantee the same API usage for both clsync and so-handlers.

IMHO the simplest and safest way will be to remove all #ifdef conditionals from public headers at all (except for a stuff defined in these public headers). This will increase memory usage a bit, but we already have a lot of predefined arrays (instead of malloc'ed), so this is not an issue.

Alternative solution will be to provide clsync.pc file with required CPPFLAGS. But this is not enought and there should be some runtime way to check that clsync API matches so-handler API.

I'm voting for ifdef-free public API.

And please, bump CLSYNC_API_VERSION each time public api changes (or add some hook doing so).

@xaionaro xaionaro added this to the 0.4.2 milestone May 25, 2015
@bircoph bircoph modified the milestones: 0.4.2, 0.6 May 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants