Skip to content
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

Fixed a crash on a malformed delete event #1743

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

mplorentz
Copy link
Member

Issues covered

#170

Description

A quick crash fix for something I came across while working on another ticket.

How to test

Run the unit tests. If you'd like you can revert the changes in Event+CoreDataClass.swift and verify that the test crashes.

let pubkey = components[1]

guard pubkey == author.hexadecimalPublicKey else {
guard let pubkey = components[safe: 1],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, my fault. All direct array access should be done safely like this. Thanks!

@bryanmontz bryanmontz added this pull request to the merge queue Jan 29, 2025
@pelumy
Copy link
Contributor

pelumy commented Jan 29, 2025

Why / how can a delete event be malformed?

@bryanmontz
Copy link
Contributor

Why / how can a delete event be malformed?

Because nostr is an open, permissionless protocol, any implementer of any app could send incorrectly formatted information, such as tags that don't actually follow the nostr spec. Therefore we have to code very defensively.

Merged via the queue into main with commit 55a55c4 Jan 29, 2025
4 checks passed
@bryanmontz bryanmontz deleted the fix-malformed-delete-crash branch January 29, 2025 12:27
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.

3 participants