]> gitweb.ps.run Git - matrix_esp_thesis/commitdiff
use global static buffers to save memory, get Verify example working on ESP32
authorpatrick-scho <patrick.schoenberger@posteo.de>
Sun, 15 Oct 2023 12:11:51 +0000 (14:11 +0200)
committerpatrick-scho <patrick.schoenberger@posteo.de>
Sun, 15 Oct 2023 12:11:51 +0000 (14:11 +0200)
esp32/esp_project/main/Verify.c
src/matrix.c
src/matrix.h
src/matrix_http_esp32.c

index 124ddd22b1cfb5b059a0ce5caf17257d1d139956..0ac7183265a220f22b37353aa28ba1938d835323 100644 (file)
@@ -62,9 +62,9 @@ HandleEvent(
         OlmUtility * olmUtil = olm_utility(malloc(olm_utility_size()));
         
         STATIC char publicKey[64];
-        STATIC char keyStartJsonCanonical[128];
-        STATIC char concat[128+64];
-        STATIC char commitment[256];
+        STATIC char keyStartJsonCanonical[512];
+        STATIC char concat[512+64];
+        STATIC char commitment[1024];
         olm_sas_get_pubkey(olmSas,
             publicKey,
             64);
@@ -73,15 +73,15 @@ HandleEvent(
         const char * keyStartJson;
         int keyStartJsonLen;
         mjson_find(event, eventLen, "$.content", &keyStartJson, &keyStartJsonLen);
-        JsonCanonicalize(keyStartJson, keyStartJsonLen, keyStartJsonCanonical, 128);
+        JsonCanonicalize(keyStartJson, keyStartJsonLen, keyStartJsonCanonical, 512);
 
         printf("json:\n%.*s\ncanonical json:\n%s\n", keyStartJsonLen, keyStartJson, keyStartJsonCanonical);
 
         int concatLen =
-            snprintf(concat, 128+64, "%.*s%s", olm_sas_pubkey_length(olmSas), publicKey, keyStartJsonCanonical);
+            snprintf(concat, 512+64, "%.*s%s", olm_sas_pubkey_length(olmSas), publicKey, keyStartJsonCanonical);
 
         int commitmentLen =
-            olm_sha256(olmUtil, concat, concatLen, commitment, 256);
+            olm_sha256(olmUtil, concat, concatLen, commitment, 1024);
         
         STATIC char verificationAcceptBuffer[512];
         snprintf(verificationAcceptBuffer, 512,
@@ -293,16 +293,22 @@ HandleEvent(
             mjson_get_string(event, eventLen, jp, encrypted, 2048);
 
             MatrixOlmSession * olmSession;
-            if (messageTypeInt == 0) {
-                MatrixClientGetOlmSessionIn(client,
-                    USER_ID,
-                    DEVICE_ID,
-                    &olmSession);
-            } else {
-                MatrixClientGetOlmSessionOut(client,
-                    USER_ID,
-                    DEVICE_ID,
-                    &olmSession);
+            
+            if (! MatrixClientGetOlmSession(client, USER_ID, DEVICE_ID, &olmSession))
+            {
+                if (messageTypeInt == 0) {
+                    MatrixClientNewOlmSessionIn(client,
+                        USER_ID,
+                        DEVICE_ID,
+                        encrypted,
+                        &olmSession);
+                }
+                else {
+                    MatrixClientNewOlmSessionOut(client,
+                        USER_ID,
+                        DEVICE_ID,
+                        &olmSession);
+                }
             }
 
             printf("event: %.*s\n", eventLen, event);
@@ -380,17 +386,19 @@ HandleRoomEvent(
 void
 Sync(
     MatrixClient * client,
-    char * syncBuffer
-{
+    char * syncBuffer, int syncBufferLen)
+{
     STATIC char nextBatch[1024] = {0};
 
-    MatrixClientSync(client, syncBuffer, 1024, nextBatch);
+    MatrixClientSync(client, syncBuffer, syncBufferLen, nextBatch);
     
     int res;
 
     const char * s = syncBuffer;
     int slen = strlen(syncBuffer);
     
+    printf("sync:\n\n%s\n\n", syncBuffer);
+    
     // {
     // int koff, klen, voff, vlen, vtype, off = 0;
     // for (off = 0; (off = mjson_next(s, slen, off, &koff, &klen,
@@ -465,9 +473,15 @@ Sync(
 int
 main(void)
 {
-    STATIC MatrixClient _client;
-    MatrixClient * client = &_client;
-    // MatrixClient * client = (MatrixClient*)malloc(sizeof(MatrixClient));
+    // sizeof(MatrixOlmAccount);
+    // sizeof(MatrixMegolmInSession);
+    // sizeof(MatrixMegolmOutSession);
+    // sizeof(MatrixOlmSession);    
+    // sizeof(MatrixDevice);
+
+    // STATIC MatrixClient _client;
+    // MatrixClient * client = &_client;
+    MatrixClient * client = (MatrixClient*)malloc(sizeof(MatrixClient));
     MatrixClientInit(client);
 
     MatrixHttpInit(&client->hc, SERVER);
@@ -488,40 +502,48 @@ main(void)
         EVENT_ID,
         eventBuffer, 1024);
     printf("event: %s\n", eventBuffer);
-    
-    char * syncBuffer = (char*)malloc(1024*40);
-    // STATIC char syncBuffer[1024];
 
-    while (! verified)
-        Sync(client, syncBuffer);
+    #define SYNC_BUFFER_SIZE 1024*10
+
+    // char * syncBuffer = (char*)malloc(SYNC_BUFFER_SIZE);
+    STATIC char syncBuffer[SYNC_BUFFER_SIZE];
+
+    while (! verified) {
+        Sync(client, syncBuffer, SYNC_BUFFER_SIZE);
+    }
+
+    printf("verified!\n");
     
-    // while (getchar() != 'q')
-    //     Sync(client, syncBuffer);
+    int c;
+    while ((c=getchar()) != 'q') {
+        printf("getchar() = %c [%d]\n", c, c);
+        Sync(client, syncBuffer, SYNC_BUFFER_SIZE);
+    }
     
-    MatrixClientRequestMegolmInSession(client,
-        ROOM_ID,
-        SESSION_ID,
-        SENDER_KEY,
-        USER_ID,
-        DEVICE_ID);
-
-    MatrixMegolmInSession * megolmInSession;
-    while (! MatrixClientGetMegolmInSession(client,
-        ROOM_ID, strlen(ROOM_ID),
-        SESSION_ID, strlen(SESSION_ID),
-        &megolmInSession))
-        Sync(client, syncBuffer);
-
-    int encryptedLen =
-        mjson_get_string(eventBuffer, strlen(eventBuffer), "$.content.ciphertext", encrypted, 1024);
+    // MatrixClientRequestMegolmInSession(client,
+    //     ROOM_ID,
+    //     SESSION_ID,
+    //     SENDER_KEY,
+    //     USER_ID,
+    //     DEVICE_ID);
+
+    // MatrixMegolmInSession * megolmInSession;
+    // while (! MatrixClientGetMegolmInSession(client,
+    //     ROOM_ID, strlen(ROOM_ID),
+    //     SESSION_ID, strlen(SESSION_ID),
+    //     &megolmInSession))
+    //     Sync(client, syncBuffer, SYNC_BUFFER_SIZE);
+
+    // int encryptedLen =
+    //     mjson_get_string(eventBuffer, strlen(eventBuffer), "$.content.ciphertext", encrypted, 1024);
     
-    printf("encrypted: [%.*s]\n", encryptedLen, encrypted);
+    // printf("encrypted: [%.*s]\n", encryptedLen, encrypted);
 
-    MatrixMegolmInSessionDecrypt(megolmInSession,
-        encrypted, encryptedLen,
-        decrypted, 1024);
+    // MatrixMegolmInSessionDecrypt(megolmInSession,
+    //     encrypted, encryptedLen,
+    //     decrypted, 1024);
 
-    printf("decrypted: %s\n", decrypted);
+    // printf("decrypted: %s\n", decrypted);
 
     MatrixClientDeleteDevice(client);
         
index ef094b8fad63800f0c425f7b3517fd6072bef750..fe8e1a3e241fdabb1b9ac94cc62dbb39e5b897f6 100644 (file)
@@ -8,14 +8,16 @@
 #include <esp_random.h>\r
 #endif\r
 \r
-#define STATIC\r
+#define STATIC static\r
 \r
 #define LOGIN_REQUEST_SIZE 1024\r
 #define LOGIN_RESPONSE_SIZE 1024\r
 #define LOGIN_URL "/_matrix/client/v3/login"\r
 \r
 #define ENCRYPTED_REQUEST_SIZE (1024*5)\r
+STATIC char g_EncryptedRequestBuffer[ENCRYPTED_REQUEST_SIZE];\r
 #define ENCRYPTED_EVENT_SIZE (1024*10)\r
+STATIC char g_EncryptedEventBuffer[ENCRYPTED_EVENT_SIZE];\r
 #define ROOM_SEND_REQUEST_SIZE 256\r
 #define ROOM_SEND_RESPONSE_SIZE 1024\r
 #define ROOM_SEND_URL "/_matrix/client/v3/rooms/%s/send/%s/%d"\r
 #define ROOMKEY_REQUEST_SIZE (1024*4)\r
 \r
 #define TODEVICE_EVENT_SIZE (1024*5)\r
+STATIC char g_TodeviceEventBuffer[TODEVICE_EVENT_SIZE];\r
 #define TODEVICE_URL "/_matrix/client/v3/sendToDevice/%s/%d"\r
 \r
 #define KEYS_QUERY_URL "/_matrix/client/v3/keys/query"\r
 #define KEYS_QUERY_REQUEST_SIZE 256\r
-#define KEYS_QUERY_RESPONSE_SIZE (1024*10)\r
+#define KEYS_QUERY_RESPONSE_SIZE (1024*5)\r
 \r
 #define KEYS_UPLOAD_URL "/_matrix/client/v3/keys/upload"\r
 #define KEYS_UPLOAD_REQUEST_SIZE 1024*4\r
+STATIC char g_KeysUploadRequestBuffer[KEYS_UPLOAD_REQUEST_SIZE];\r
 #define KEYS_UPLOAD_REQUEST_SIGNED_SIZE 2048*4\r
+STATIC char g_KeysUploadRequestSignedBuffer[KEYS_UPLOAD_REQUEST_SIGNED_SIZE];\r
 #define KEYS_UPLOAD_RESPONSE_SIZE 2048\r
 \r
 #define KEYS_CLAIM_URL "/_matrix/client/v3/keys/claim"\r
@@ -696,9 +701,7 @@ bool
 MatrixClientUploadOnetimeKeys(\r
     MatrixClient * client)\r
 {\r
-    STATIC char requestBuffer[KEYS_UPLOAD_REQUEST_SIZE];\r
-\r
-    mjson_snprintf(requestBuffer, KEYS_UPLOAD_REQUEST_SIZE,\r
+    mjson_snprintf(g_KeysUploadRequestBuffer, KEYS_UPLOAD_REQUEST_SIZE,\r
         "{");\r
 \r
     STATIC char onetimeKeysBuffer[1024];\r
@@ -724,34 +727,33 @@ MatrixClientUploadOnetimeKeys(
             keyJson, keyJsonLen,\r
             keyJsonSigned, JSON_ONETIME_KEY_SIGNED_SIZE);\r
         \r
-        mjson_snprintf(requestBuffer+strlen(requestBuffer), KEYS_UPLOAD_REQUEST_SIZE-strlen(requestBuffer),\r
+        mjson_snprintf(g_KeysUploadRequestBuffer+strlen(g_KeysUploadRequestBuffer), KEYS_UPLOAD_REQUEST_SIZE-strlen(g_KeysUploadRequestBuffer),\r
             "\"signed_curve25519:%.*s\":%s,",\r
             klen-2, keys + koff+1,\r
             keyJsonSigned);\r
     }\r
 \r
-    if (requestBuffer[strlen(requestBuffer)-1] == ',')\r
-        requestBuffer[strlen(requestBuffer)-1] = '\0';\r
+    if (g_KeysUploadRequestBuffer[strlen(g_KeysUploadRequestBuffer)-1] == ',')\r
+        g_KeysUploadRequestBuffer[strlen(g_KeysUploadRequestBuffer)-1] = '\0';\r
 \r
-    mjson_snprintf(requestBuffer+strlen(requestBuffer), KEYS_UPLOAD_REQUEST_SIZE-strlen(requestBuffer),\r
+    mjson_snprintf(g_KeysUploadRequestBuffer+strlen(g_KeysUploadRequestBuffer), KEYS_UPLOAD_REQUEST_SIZE-strlen(g_KeysUploadRequestBuffer),\r
         "}");\r
         \r
     // STATIC char onetimeKeysSignedBuffer[KEYS_UPLOAD_REQUEST_SIGNED_SIZE];\r
     // JsonSign(client,\r
-    //     requestBuffer, strlen(requestBuffer),\r
+    //     g_KeysUploadRequestBuffer, strlen(g_KeysUploadRequestBuffer),\r
     //     onetimeKeysSignedBuffer, KEYS_UPLOAD_REQUEST_SIZE);\r
         \r
     // STATIC char finalEvent[KEYS_UPLOAD_REQUEST_SIGNED_SIZE];\r
     // snprintf(finalEvent, KEYS_UPLOAD_REQUEST_SIGNED_SIZE,\r
     // "{\"one_time_keys\":%s}", onetimeKeysSignedBuffer);\r
-    STATIC char finalEvent[KEYS_UPLOAD_REQUEST_SIGNED_SIZE];\r
-    snprintf(finalEvent, KEYS_UPLOAD_REQUEST_SIGNED_SIZE,\r
-    "{\"one_time_keys\":%s}", requestBuffer);\r
+    snprintf(g_KeysUploadRequestSignedBuffer, KEYS_UPLOAD_REQUEST_SIGNED_SIZE,\r
+    "{\"one_time_keys\":%s}", g_KeysUploadRequestBuffer);\r
 \r
     STATIC char responseBuffer[KEYS_UPLOAD_RESPONSE_SIZE];\r
     MatrixHttpPost(client->hc,\r
         KEYS_UPLOAD_URL,\r
-        finalEvent,\r
+        g_KeysUploadRequestSignedBuffer,\r
         responseBuffer, KEYS_UPLOAD_RESPONSE_SIZE,\r
         true);\r
 \r
@@ -768,10 +770,8 @@ MatrixClientUploadDeviceKey(
     char thisSigningKey[DEVICE_KEY_SIZE];\r
     MatrixOlmAccountGetSigningKey(&client->olmAccount, thisSigningKey, DEVICE_KEY_SIZE);\r
 \r
-    STATIC char deviceKeysBuffer[KEYS_UPLOAD_REQUEST_SIZE];\r
-\r
     int deviceKeysBufferLen =\r
-        mjson_snprintf(deviceKeysBuffer, KEYS_UPLOAD_REQUEST_SIZE,\r
+        mjson_snprintf(g_KeysUploadRequestBuffer, KEYS_UPLOAD_REQUEST_SIZE,\r
             "{"\r
                 "\"algorithms\":[\"m.olm.v1.curve25519-aes-sha2\",\"m.megolm.v1.aes-sha2\"],"\r
                 "\"device_id\":\"%s\","\r
@@ -786,14 +786,13 @@ MatrixClientUploadDeviceKey(
             client->deviceId, thisSigningKey,\r
             client->userId);\r
 \r
-    STATIC char deviceKeysSignedBuffer[KEYS_UPLOAD_REQUEST_SIGNED_SIZE];\r
     JsonSign(client,\r
-        deviceKeysBuffer, deviceKeysBufferLen,\r
-        deviceKeysSignedBuffer, KEYS_UPLOAD_REQUEST_SIZE);\r
+        g_KeysUploadRequestBuffer, deviceKeysBufferLen,\r
+        g_KeysUploadRequestSignedBuffer, KEYS_UPLOAD_REQUEST_SIZE);\r
     \r
     STATIC char finalEvent[KEYS_UPLOAD_REQUEST_SIGNED_SIZE+30];\r
     snprintf(finalEvent, KEYS_UPLOAD_REQUEST_SIGNED_SIZE+30,\r
-    "{\"device_keys\":%s}", deviceKeysSignedBuffer);\r
+    "{\"device_keys\":%s}", g_KeysUploadRequestSignedBuffer);\r
 \r
     STATIC char responseBuffer[KEYS_UPLOAD_RESPONSE_SIZE];\r
     MatrixHttpPost(client->hc,\r
@@ -966,10 +965,9 @@ MatrixClientSendEventEncrypted(
         MatrixClientNewMegolmOutSession(client, roomId, &outSession);\r
         \r
     // encrypt\r
-    STATIC char encryptedBuffer[ENCRYPTED_REQUEST_SIZE/10];\r
     MatrixMegolmOutSessionEncrypt(outSession,\r
         requestBuffer,\r
-        encryptedBuffer, ENCRYPTED_REQUEST_SIZE);\r
+        g_EncryptedRequestBuffer, ENCRYPTED_REQUEST_SIZE);\r
 \r
     char thisDeviceKey[DEVICE_KEY_SIZE];\r
     MatrixOlmAccountGetDeviceKey(&client->olmAccount, thisDeviceKey, DEVICE_KEY_SIZE);\r
@@ -980,8 +978,7 @@ MatrixClientSendEventEncrypted(
     const char * sessionId = outSession->id;\r
     const char * deviceId = client->deviceId;\r
 \r
-    STATIC char encryptedEventBuffer[ENCRYPTED_EVENT_SIZE/10];\r
-    sprintf(encryptedEventBuffer,\r
+    snprintf(g_EncryptedEventBuffer, ENCRYPTED_EVENT_SIZE,\r
         "{"\r
         "\"algorithm\":\"m.megolm.v1.aes-sha2\","\r
         "\"ciphertext\":\"%s\","\r
@@ -989,7 +986,7 @@ MatrixClientSendEventEncrypted(
         "\"sender_key\":\"%s\","\r
         "\"session_id\":\"%s\""\r
         "}",\r
-        encryptedBuffer,\r
+        g_EncryptedRequestBuffer,\r
         deviceId,\r
         senderKey,\r
         sessionId);\r
@@ -998,7 +995,7 @@ MatrixClientSendEventEncrypted(
     return MatrixClientSendEvent(client,\r
         roomId,\r
         "m.room.encrypted",\r
-        encryptedEventBuffer);\r
+        g_EncryptedEventBuffer);\r
 }\r
 \r
 // https://spec.matrix.org/v1.6/client-server-api/#get_matrixclientv3sync\r
@@ -1011,8 +1008,10 @@ MatrixClientSync(
     // filter={\"event_fields\":[\"to_device\"]}\r
     STATIC char url[MAX_URL_LEN];\r
     snprintf(url, MAX_URL_LEN,\r
-        "/_matrix/client/v3/sync?timeout=%d%s",\r
+        "/_matrix/client/v3/sync?timeout=%d" "%s" "%s",\r
         SYNC_TIMEOUT,\r
+        "",\r
+        // "&filter={\"event_fields\":[\"to_device\"]}",\r
         strlen(nextBatch) > 0 ? "&since=" : "");\r
     \r
     int index = strlen(url);\r
@@ -1253,7 +1252,7 @@ MatrixClientRequestMegolmInSession(
 }\r
 \r
 bool\r
-MatrixClientGetOlmSessionIn(\r
+MatrixClientGetOlmSession(\r
     MatrixClient * client,\r
     const char * userId,\r
     const char * deviceId,\r
@@ -1303,25 +1302,6 @@ MatrixClientNewOlmSessionIn(
     return false;\r
 }\r
 \r
-bool\r
-MatrixClientGetOlmSessionOut(\r
-    MatrixClient * client,\r
-    const char * userId,\r
-    const char * deviceId,\r
-    MatrixOlmSession ** outSession)\r
-{\r
-    for (int i = 0; i < client->numOlmSessions; i++)\r
-    {\r
-        if (strcmp(client->olmSessions[i].deviceId, deviceId) == 0)\r
-        {\r
-            *outSession = &client->olmSessions[i];\r
-            return true;\r
-        }\r
-    }\r
-\r
-    return false;\r
-}\r
-\r
 bool\r
 MatrixClientNewOlmSessionOut(\r
     MatrixClient * client,\r
@@ -1372,8 +1352,7 @@ MatrixClientSendToDevice(
     sprintf(requestUrl,\r
         TODEVICE_URL, msgType, (int)time(NULL));\r
 \r
-    STATIC char eventBuffer[TODEVICE_EVENT_SIZE];\r
-    snprintf(eventBuffer, TODEVICE_EVENT_SIZE,\r
+    snprintf(g_TodeviceEventBuffer, TODEVICE_EVENT_SIZE,\r
         "{"\r
             "\"messages\":{"\r
                 "\"%s\":{"\r
@@ -1389,7 +1368,7 @@ MatrixClientSendToDevice(
     bool result =\r
         MatrixHttpPut(client->hc,\r
             requestUrl,\r
-            eventBuffer,\r
+            g_TodeviceEventBuffer,\r
             responseBuffer, ROOM_SEND_RESPONSE_SIZE,\r
             true);\r
     \r
@@ -1408,7 +1387,7 @@ MatrixClientSendToDeviceEncrypted(
 {\r
     // get olm session\r
     MatrixOlmSession * olmSession;\r
-    if (! MatrixClientGetOlmSessionOut(client, userId, deviceId, &olmSession))\r
+    if (! MatrixClientGetOlmSession(client, userId, deviceId, &olmSession))\r
         MatrixClientNewOlmSessionOut(client, userId, deviceId, &olmSession);\r
 \r
     // create event json\r
@@ -1420,8 +1399,7 @@ MatrixClientSendToDeviceEncrypted(
     char thisSigningKey[DEVICE_KEY_SIZE];\r
     MatrixOlmAccountGetSigningKey(&client->olmAccount, thisSigningKey, DEVICE_KEY_SIZE);\r
 \r
-    STATIC char eventBuffer[TODEVICE_EVENT_SIZE];\r
-    sprintf(eventBuffer,\r
+    snprintf(g_TodeviceEventBuffer, TODEVICE_EVENT_SIZE,\r
         "{"\r
         "\"type\":\"%s\","\r
         "\"content\":%s,"\r
@@ -1442,17 +1420,14 @@ MatrixClientSendToDeviceEncrypted(
         thisSigningKey);\r
 \r
     // encrypt\r
-    STATIC char encryptedBuffer[ENCRYPTED_REQUEST_SIZE];\r
     MatrixOlmSessionEncrypt(olmSession,\r
-        eventBuffer,\r
-        encryptedBuffer, ENCRYPTED_REQUEST_SIZE);\r
+        g_TodeviceEventBuffer,\r
+        g_EncryptedRequestBuffer, ENCRYPTED_REQUEST_SIZE);\r
 \r
     char thisDeviceKey[DEVICE_KEY_SIZE];\r
     MatrixOlmAccountGetDeviceKey(&client->olmAccount, thisDeviceKey, DEVICE_KEY_SIZE);\r
 \r
-\r
-    STATIC char encryptedEventBuffer[ENCRYPTED_EVENT_SIZE];\r
-    sprintf(encryptedEventBuffer,\r
+    snprintf(g_EncryptedEventBuffer, ENCRYPTED_EVENT_SIZE,\r
         "{"\r
         "\"algorithm\":\"m.olm.v1.curve25519-aes-sha2\","\r
         "\"ciphertext\":{"\r
@@ -1465,7 +1440,7 @@ MatrixClientSendToDeviceEncrypted(
         "\"sender_key\":\"%s\""\r
         "}",\r
         targetDeviceKey,\r
-        encryptedBuffer,\r
+        g_EncryptedRequestBuffer,\r
         olm_session_has_received_message(olmSession->session),\r
         client->deviceId,\r
         thisDeviceKey);\r
@@ -1475,7 +1450,7 @@ MatrixClientSendToDeviceEncrypted(
         client,\r
         userId,\r
         deviceId,\r
-        encryptedEventBuffer,\r
+        g_EncryptedEventBuffer,\r
         "m.room.encrypted");\r
 }\r
 \r
index d31a7f6abd8f4d9b01173b14e8101b1fde320b72..c07c742b0f6463a841d5f7810933d7c1d93c25c6 100644 (file)
@@ -47,9 +47,9 @@
 #define JSON_ONETIME_KEY_SIGNED_SIZE 256\r
 #define JSON_SIGNATURE_SIZE 256\r
 \r
-#define NUM_MEGOLM_SESSIONS 10\r
-#define NUM_OLM_SESSIONS 10\r
-#define NUM_DEVICES 10\r
+#define NUM_MEGOLM_SESSIONS 2\r
+#define NUM_OLM_SESSIONS 2\r
+#define NUM_DEVICES 5\r
 \r
 // HTTP\r
 \r
@@ -401,7 +401,7 @@ MatrixClientRequestMegolmInSession(
     const char * deviceId); // TODO: remove deviceId (query all devices)\r
 \r
 bool\r
-MatrixClientGetOlmSessionIn(\r
+MatrixClientGetOlmSession(\r
     MatrixClient * client,\r
     const char * userId,\r
     const char * deviceId,\r
@@ -415,13 +415,6 @@ MatrixClientNewOlmSessionIn(
     const char * encrypted,\r
     MatrixOlmSession ** outSession);\r
     \r
-bool\r
-MatrixClientGetOlmSessionOut(\r
-    MatrixClient * client,\r
-    const char * userId,\r
-    const char * deviceId,\r
-    MatrixOlmSession ** outSession);\r
-    \r
 bool\r
 MatrixClientNewOlmSessionOut(\r
     MatrixClient * client,\r
index 3faf9f5dd1aef66e5881ceaf90cacd67f89d7e05..874afd81bdf97943c64978f0e8113248177e552b 100644 (file)
@@ -98,6 +98,7 @@ esp_err_t _http_event_handler(esp_http_client_event_t *evt)
             copy_len = MIN(evt->data_len, (hc->dataCap - hc->dataLen));
             if (copy_len) {
                 memcpy(hc->data + hc->dataLen, evt->data, copy_len);
+                hc->data[hc->dataLen + copy_len] = '\0';
             }
 
             hc->dataLen += copy_len;