Skip to contentSkip to conversation

client: Increase passphrase buffer to accommodate for nil byte

PATCH In review Tim Kourt 2 participants 3 messages Oct 29, 2019

lore
Share & tools
lore

Tim Kourt

author
#0 lore raw

PATCH v2 1/2 client: Increase passphrase buffer to accommodate for nil byte

---
 client/display.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
client/display.c +2 -2
index cd17ad84..105d05cb 100644
@@ -397,7 +397,7 @@ static void display_completion_matches(char **matches, int num_matches,
 
 static struct masked_input {
 	bool use_mask;
-	char passphrase[MAX_PASSPHRASE_LEN];
+	char passphrase[MAX_PASSPHRASE_LEN + 1];
 	uint8_t point;
 	uint8_t end;
 } masked_input;
@@ -453,7 +453,7 @@ done:
 
 static void reset_masked_input(void)
 {
-	memset(masked_input.passphrase, 0, MAX_PASSPHRASE_LEN);
+	memset(masked_input.passphrase, 0, MAX_PASSPHRASE_LEN + 1);
 	masked_input.point = 0;
 	masked_input.end = 0;
 }
Signature · 1 line
2.13.6
author
#1 lore raw

PATCH v2 2/2 client: Update rl_point to last known position

Keep cursor's position consistent when passphrase is reaching its maximum by adding characters in the middle of the string

The use case is very rare as not many people will attempt to modify the masked passphrase from the middle.

---
 client/display.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
client/display.c +3 -1
index 105d05cb..10c87b2a 100644
@@ -408,7 +408,9 @@ static void mask_input(void)
 		return;
 
 	if (rl_end > MAX_PASSPHRASE_LEN) {
-		rl_point = rl_end = MAX_PASSPHRASE_LEN;
+		rl_end = MAX_PASSPHRASE_LEN;
+		rl_point = masked_input.point;
+
 		goto set_mask;
 	}
 
Signature · 1 line
2.13.6
#2 lore raw
In reply to Tim Kourt

Hi Tim,

Quoted 4 lines · Tim Kourt
---
  client/display.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

Both applied, thanks

Regards,
-Denis