From 2e0be1c6c061be9a6a04f4afa793a2842a7e0761 Mon Sep 17 00:00:00 2001 From: coding-agent-contributor Date: Wed, 5 Jun 2024 10:00:46 +0000 Subject: [PATCH 1/2] Fix buffer overflow issue by adjusting input buffer size and fgets usage --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 08abd2f..7fdd31b 100644 --- a/main.c +++ b/main.c @@ -3,10 +3,10 @@ int main() { - char name[64]; + char name[128]; printf("Enter your name:\n"); - fgets(name, sizeof(name) + 32, stdin); + fgets(name, sizeof(name), stdin); // Remove the trailing newline character if present name[strcspn(name, "\n")] = '\0'; From 9c2408604ddf5c0b263fcc7f0d62a29146f83eab Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 10 Jun 2024 15:02:06 +0000 Subject: [PATCH 2/2] Fix buffer overflow issue by limiting fgets input size --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 08abd2f..21a339c 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ int main() char name[64]; printf("Enter your name:\n"); - fgets(name, sizeof(name) + 32, stdin); + fgets(name, sizeof(name), stdin); // Remove the trailing newline character if present name[strcspn(name, "\n")] = '\0';