-
Notifications
You must be signed in to change notification settings - Fork 88
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
Add interactive Key-Value app #325
Conversation
examples/tests/kv_interactive/main.c
Outdated
int value_start = key_end + 1; | ||
int value_end = find_end(value_start); | ||
int value_len = value_end - value_start; | ||
|
||
memcpy(key_buf, read_buf + key_start, key_len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If key_end is 64 then won't this overflow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worst case is it copies the entire buffer minus the "set " at the beginning, so it should fit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the worst case an overflow?
If key_end
is 64 then we have the following:
int key_start = 4;
int key_end = 64; // A valid result from find_end()
int key_len = 60;
int value_start = 65;
int value_end = ??;
int value_len = ??;
char read_buf[64];
This memcpy()
will become:
memcpy(key_buf, read_buf + 4, 60);
which is ok,
key_buf[60] = '\0';
Seems like the wrong place to set the terminator though
but
memcpy(value_buf, read_buf + 65, ??);
Is an overflow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors r+
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page.
|
This app can set/get/delete keys through stdin.
I also added sync functions to make the app easier to write.