-
Notifications
You must be signed in to change notification settings - Fork 5
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
at_c: non-encrypted notifications cause a segfault #246
Comments
Not a high priority since only encrypted notifications are ever used in the C Daemon |
Setting this to blocked because some work I believe is needed to be done on the atServer side of things - atsign-foundation/at_server#2050 |
No longer blocked, as this is implemented in the protocol now. Setting it to triage now |
Current investigation shows that non-encrypted notifications cause a segfault still. Monitor code: #include <atlogger/atlogger.h>
#include <atclient/atclient.h>
#include <atclient/monitor.h>
#define ATSIGN "@12alpaca"
#define KEYS_PATH "/home/jeremy/.atsign/keys/@12alpaca_key.atKeys"
#define TAG "main"
int main() {
int ret = 1;
atlogger_set_logging_level(ATLOGGER_LOGGING_LEVEL_DEBUG);
atclient main_client;
atclient_init(&main_client);
atclient monitor_client;
atclient_init(&monitor_client);
atclient_atkeys atkeys;
atclient_atkeys_init(&atkeys);
if((ret = atclient_atkeys_populate_from_path(&atkeys, KEYS_PATH)) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "Failed to populate atkeys from path\n");
goto exit;
}
if((ret = atclient_pkam_authenticate(&main_client, ATSIGN, &atkeys, NULL, NULL)) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "Failed to authenticate connection\n");
goto exit;
}
if((ret = atclient_monitor_pkam_authenticate(&monitor_client, ATSIGN, &atkeys, NULL)) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "Failed to authenticate monitor connection\n");
goto exit;
}
if((ret = atclient_monitor_start(&monitor_client, ".*")) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "Failed to start monitor\n");
goto exit;
}
while(1) {
atclient_monitor_message message;
atclient_monitor_message_init(&message);
ret = atclient_monitor_read(&monitor_client, &main_client, &message, NULL);
if(message.type == ATCLIENT_MONITOR_MESSAGE_TYPE_NOTIFICATION) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_INFO, "Received notification:");
atlogger_log(NULL, ATLOGGER_LOGGING_LEVEL_INFO, "%s", message.notification->decrypted_value);
atlogger_log(NULL, ATLOGGER_LOGGING_LEVEL_INFO, "\n");
}
atclient_monitor_message_free(&message);
}
ret = 0;
exit: { return ret; }
} Monitor code output:
Notification code: #include <atlogger/atlogger.h>
#include <atclient/notify.h>
#include <atclient/atclient.h>
#define TAG "main"
#define ATSIGN "@12snowboating"
#define KEYS_PATH "/home/jeremy/.atsign/keys/@12snowboating_key.atKeys"
int main() {
int ret = 1;
atlogger_set_logging_level(ATLOGGER_LOGGING_LEVEL_DEBUG);
atclient main_client;
atclient_init(&main_client);
atclient_atkeys atkeys;
atclient_atkeys_init(&atkeys);
atclient_atkey atkey;
atclient_atkey_init(&atkey);
atclient_notify_params params;
atclient_notify_params_init(¶ms);
if((ret = atclient_atkeys_populate_from_path(&atkeys, KEYS_PATH)) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "Failed to populate atkeys from path\n");
goto exit;
}
if((ret = atclient_pkam_authenticate(&main_client, ATSIGN, &atkeys, NULL, NULL)) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "Failed to authenticate connection\n");
goto exit;
}
if((ret = atclient_atkey_create_shared_key(&atkey, "non_encrypted_notification", "@12snowboating", "@12alpaca", "test")) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "Failed to create shared key\n");
goto exit;
}
if((ret = atclient_notify_params_set_atkey(¶ms, &atkey)) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "Failed to set atkey\n");
goto exit;
}
if((ret = atclient_notify_params_set_value(¶ms, "Hello, World!")) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "Failed to set value\n");
goto exit;
}
if((ret = atclient_notify_params_set_should_encrypt(¶ms, false)) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "Failed to set should_encrypt\n");
goto exit;
}
// print params
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_INFO, "Params:\n");
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_INFO, " atkey: %p\n", params.atkey);
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_INFO, " value: %s\n", params.value);
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_INFO, " should_encrypt: %d\n", params.should_encrypt);
if((ret = atclient_notify(&main_client, ¶ms, NULL)) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "Failed to send notification\n");
goto exit;
}
ret = 0;
exit: { return ret; }
} Notification code output:
|
When set
shouldencrypt=false
when sending a notification, it will sendisEncrypted:false
and send the value in plain text (unencrypted). This willc ause a segfault.This ticket is dependent on atsign-foundation/at_server#1944
The text was updated successfully, but these errors were encountered: