From c864041fa047df542d6480d22e19220041fd5cc0 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Mon, 17 Jan 2022 21:46:32 +0000 Subject: [PATCH] Fix a handful of errors and warnings I've seen. Gets further running in docker, now. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3773 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- Dockerfile | 2 +- core/app.js | 1 - core/client.js | 6 +++++- core/core.js | 2 +- src/ssb.db.c | 5 ++++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4478fa32..8b05f1fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,4 +19,4 @@ COPY --from=build /app/apps /app/apps COPY --from=build /app/core /app/core WORKDIR /app EXPOSE 12345 -CMD ["/app/out/release/tildefriends"] +ENTRYPOINT ["/app/out/release/tildefriends"] diff --git a/core/app.js b/core/app.js index 2b830d11..c90b96fc 100644 --- a/core/app.js +++ b/core/app.js @@ -60,7 +60,6 @@ function socket(request, response, client) { blobId = await new Database(user).get('path:' + path); if (!blobId) { response.send(JSON.stringify({action: "error", error: message.path + ' not found'}), 0x1); - request.close(); } } response.send(JSON.stringify({action: "session", credentials: credentials}), 0x1); diff --git a/core/client.js b/core/client.js index 11c46d17..30472fc6 100644 --- a/core/client.js +++ b/core/client.js @@ -422,7 +422,11 @@ function receive(message) { } else if (message && message.action == "ping") { gSocket.send(JSON.stringify({action: "pong"})); } else if (message && message.action == "error") { - setStatusMessage(message.error.message + '\n' + message.error.stack, '#f00', false); + if (typeof(message.error) == 'string') { + setStatusMessage(message.error, '#f00', false); + } else { + setStatusMessage(message.error.message + '\n' + message.error.stack, '#f00', false); + } console.log(message.error); } } diff --git a/core/core.js b/core/core.js index 49793fd7..38faed93 100644 --- a/core/core.js +++ b/core/core.js @@ -546,7 +546,7 @@ async function loadSettings() { gGlobalSettings = JSON.parse(data); } } catch (error) { - print("Error loading settings from " + kGlobalSettingsFile + ": " + error); + print("Error loading settings from " + kGlobalSettingsFile + ":", error); } } diff --git a/src/ssb.db.c b/src/ssb.db.c index 8ba52fdf..41bcb20d 100644 --- a/src/ssb.db.c +++ b/src/ssb.db.c @@ -192,7 +192,10 @@ bool tf_ssb_db_blob_get(tf_ssb_t* ssb, const char* id, uint8_t** out_blob, size_ if (out_blob) { *out_blob = malloc(size + 1); - memcpy(*out_blob, blob, size); + if (size) + { + memcpy(*out_blob, blob, size); + } (*out_blob)[size] = '\0'; } if (out_size)