mirror of
https://github.com/Picocrypt/Picocrypt.git
synced 2025-05-12 21:58:31 +02:00
panic if comments are too long
No one is going to put >99999 characters in the comment field realistically and the UI is likely to freeze and crash before the application gets to this point. So a raw panic is sufficient for this extreme edge case.
This commit is contained in:
parent
e8fe27855f
commit
6ea23b8a86
1 changed files with 5 additions and 0 deletions
|
@ -18,6 +18,7 @@ import (
|
||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/subtle"
|
"crypto/subtle"
|
||||||
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash"
|
"hash"
|
||||||
|
@ -1316,6 +1317,10 @@ func work() {
|
||||||
// Write the program version to file
|
// Write the program version to file
|
||||||
_, errs[0] = fout.Write(rsEncode(rs5, []byte(version)))
|
_, errs[0] = fout.Write(rsEncode(rs5, []byte(version)))
|
||||||
|
|
||||||
|
if len(comments) > 99999 {
|
||||||
|
panic(errors.New("comments exceed maximum length"))
|
||||||
|
}
|
||||||
|
|
||||||
// Encode and write the comment length to file
|
// Encode and write the comment length to file
|
||||||
commentsLength := []byte(fmt.Sprintf("%05d", len(comments)))
|
commentsLength := []byte(fmt.Sprintf("%05d", len(comments)))
|
||||||
_, errs[1] = fout.Write(rsEncode(rs5, commentsLength))
|
_, errs[1] = fout.Write(rsEncode(rs5, commentsLength))
|
||||||
|
|
Loading…
Add table
Reference in a new issue