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

can we handle the value contain \0? #46

Open
xiaoyulei opened this issue Feb 13, 2017 · 6 comments
Open

can we handle the value contain \0? #46

xiaoyulei opened this issue Feb 13, 2017 · 6 comments

Comments

@xiaoyulei
Copy link

We try to write key-value pair but the value is binary, contain \0. It can not store all value into etcd.

@shafreeck
Copy link
Owner

cetcd use redis's sds to handle string. It is supported to write binary. Do you have more details?

@xiaoyulei
Copy link
Author

xiaoyulei commented Feb 14, 2017

all the function parameter is char*, like cetcd_set(cetcd_client *cli, const char *key, const char *value, uint64_t ttl) , if we write binary, it will make \0 as end character.
value_escaped = curl_easy_escape(cli->curl, value, strlen(value)); strlen will end with \0

@shafreeck
Copy link
Owner

shafreeck commented Feb 14, 2017

@YuleiXiao In fact, you can pass a cetcd_string as the parameter. It is actually a sds type.

@thkukuk
Copy link

thkukuk commented Feb 14, 2017

Passing a cetcd_string to cetcd_set() will not solve the problem, since strlen is a libc string function and not a sds function. You have to adjust all string functions in cetcd to only use sds functions and nothing else. This would be a binary incompatible change breaking all existing applications.

@shafreeck
Copy link
Owner

shafreeck commented Feb 17, 2017

@thkukuk Yeah, you are right. I will think about how to support binary safe string

@eintr
Copy link

eintr commented May 16, 2017

Further more, you can't expect a JSON interface to support binary directly. Just take base64.

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

4 participants