Skip to content

Fix frontend bugs - #22

Merged
michlopicki merged 21 commits into
mainfrom
fix/frontend-basics
Nov 25, 2026
Merged

michlopicki merged 21 commits into
mainfrom
fix/frontend-basics

Conversation

@michlopicki

Copy link
Copy Markdown
Contributor

Fixes the frontend issues from the code audit (#5–#10), one change per commit.

Crashes and memory errors

  • Choosing an account wrote one byte past the name buffer (crashed on macOS)
  • Cancel in the Compose window used the window after it was deleted
  • A missing or damaged config.json no longer crashes the login dialog

Login and new account

  • Focus starts on the account list / first field, so Enter no longer closes the app
  • Double click or Space on an account works like "Choose"
  • The new account form has readable labels, the same length limit for all fields
    and validation (empty fields, email address, host URLs, duplicates)
  • config.json is saved as 0600, it holds passwords

Compose

  • The body is read correctly from the editor's gap buffer (it used to be cut off
    or contain garbage after editing in the middle)
  • Empty fields show a message; a failed send keeps the window open
  • From is read-only; the window is no longer created at startup; F2 opens it

Backend change

  • Mailbox::send() and Application::send_email() return whether sending succeeded

Testing

Built with AddressSanitizer and UBSan and tested against real IMAPS (Dovecot)
and SMTPS servers: login, new account, inbox, sending, send errors, Cancel.
Builds without warnings with -Wall -Wextra -Wpedantic (frontend only),
except one in InboxWindow::updateContent, which will change with the body
rendering rework.

michlopicki added 21 commits November 25, 2026 20:25
add_compile_options() in src/frontend/CMakeLists.txt had no effect,
because the email_client_core target is created earlier. Set the
options on the frontend source files only, so the rest of the
project is not affected.
Initialize the virtual base TWindowInit first and members in
declaration order (-Wreorder), remove an unused variable and an
extra semicolon.
It was created before the login dialog, so it had an empty From
field and stayed hidden under the inbox.
InboxWindow::handleEvent called TWindow::handleEvent twice, so every
event was processed two times.
The last inserted view, the Exit button, had the focus, so pressing
Enter closed the application instead of choosing an account.
The name buffer was allocated with new and never freed. Use a buffer
on the stack instead and pass one less than its size to getText():
TListBox::getText() writes the terminating '\0' at dest[maxLen], so
the old call wrote one byte past the buffer.
The JSON parse error was not caught and terminated the application.
Show an empty account list instead.
"Choose" with an empty list did nothing, and an exception from
set_current_email_address() terminated the application.
TEditor::buffer is a gap buffer, not a null-terminated string. After
editing in the middle of the text the sent body was cut off or
contained garbage. Read it character by character with bufChar().
The Cancel button had the focus, so pressing Enter right away closed
the window.
Its value was ignored, mail is always sent from the logged in
account. Also copy the address with strnzcpy() instead of strcpy().
Mailbox::send() and Application::send_email() now return false when
the email was not sent, so the frontend can tell the user. Errors
are still logged as before.
Empty fields used to be ignored silently. Now a message says what is
missing, a failed send keeps the window open so the text is not
lost, and a successful one is confirmed.
Labels were 6 columns wide, so "SMTP Host:" and "IMAP Host:" were
cut off, and the IMAP row had a different spacing. Labels are now
linked to their fields and all fields use the same length limit
(IMAP host was 40, the rest 100).
As in the login dialog, the Exit button had the focus and Enter
closed the application.
Check that all fields are filled in, the user is an email address,
the hosts are URLs and the account does not exist yet. The account
is saved only when the form is valid, and a damaged config.json is
reported instead of crashing.
The file holds passwords in plain text but was created as 0664.
Set it to 0600 when an account is added.
close() deletes the window, but clearEvent() was called on it
afterwards. Clear the event first. AddressSanitizer reported it on
every Cancel; without it the application could crash at random.
@michlopicki
michlopicki merged commit 95bed1e into main Nov 25, 2026
4 checks passed
@michlopicki
michlopicki deleted the fix/frontend-basics branch November 25, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant