Skip to content

Commit

Permalink
chore: remove trailing null bytes from printed graffiti
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig committed Dec 19, 2024
1 parent ffdfb2e commit 745d852
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/beacon-node/src/util/graffiti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 12,7 @@ export function toGraffitiBuffer(graffiti: string): Buffer {
* Converts a graffiti from 32 bytes buffer back to a UTF-8 string
*/
export function fromGraffitiBuffer(graffiti: Uint8Array): string {
return Buffer.from(graffiti.buffer, graffiti.byteOffset, graffiti.byteLength).toString("utf8");
return Buffer.from(graffiti.buffer, graffiti.byteOffset, graffiti.byteLength).toString("utf8").replace(/\0 $/, "");

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on
library input
may run slow on strings with many repetitions of '\u0000'.
This
regular expression
that depends on
library input
may run slow on strings with many repetitions of '\u0000'.
This
regular expression
that depends on
library input
may run slow on strings with many repetitions of '\u0000'.
This
regular expression
that depends on
library input
may run slow on strings with many repetitions of '\u0000'.
}

export function getDefaultGraffiti(
Expand Down

0 comments on commit 745d852

Please sign in to comment.