aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Linskey2026-06-11 05:47:35 -0400
committerBenjamin Linskey2026-06-11 05:47:35 -0400
commit55c0be03a23d3fca4994d4d28018e0826c34fa08 (patch)
tree1736ca24700fc9aff8e4e4f254317a91fe5ec0e0
parent6bc476786626f214c9bca89f3114792d03bb16fd (diff)
downloadrogue-55c0be03a23d3fca4994d4d28018e0826c34fa08.tar.gz

Replace strcpy() and strcat() with safer functions

Switched to strlcpy() and strlcat(). Fixes a compiler warning on OpenBSD.

-rw-r--r--room.c3
-rw-r--r--save.c4
2 files changed, 4 insertions, 3 deletions
diff --git a/room.c b/room.c
index ae1f9d1..121e866 100644
--- a/room.c
+++ b/room.c
@@ -601,7 +601,8 @@ CH:
* allocated to hold MAX_OPT_LEN+2
* bytes. This is arranged in init.c.
*/
- (void)strcpy(*(options[i].strval), buf);
+ char *dst = *(options[i].strval);
+ (void)strlcpy(dst, buf, sizeof(dst));
}
opt_show(i);
goto CH;
diff --git a/save.c b/save.c
index 7f0ed95..5a272b8 100644
--- a/save.c
+++ b/save.c
@@ -106,8 +106,8 @@ save_into_file(const char *sfile)
"out of memory for save file name");
sfile = error_file;
} else {
- (void)strcpy(name_buffer, hptr);
- (void)strcat(name_buffer, sfile+1);
+ (void)strlcpy(name_buffer, hptr, sizeof(name_buffer));
+ (void)strlcat(name_buffer, sfile+1, sizeof(name_buffer));
sfile = name_buffer;
}
/*