From 75d8e596bc3472cf72051040d2586180c1a45faa Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 14 Jul 2003 17:26:43 +0000 Subject: [PATCH] * strcpy() --> safestrncpy() in a few other random places --- citadel/ChangeLog | 4 ++++ citadel/room_ops.c | 5 +++-- citadel/user_ops.c | 9 +++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index fa693039f..dcc1265ec 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,7 @@ $Log$ + Revision 607.23 2003/07/14 17:26:42 ajc + * strcpy() --> safestrncpy() in a few other random places + Revision 607.22 2003/07/14 17:12:28 ajc * Replaced strcpy() with safestrcpy() in cmd_setp() @@ -4862,3 +4865,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/room_ops.c b/citadel/room_ops.c index e2a331048..058b3ac45 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -305,7 +305,8 @@ void getfloor(struct floor *flbuf, int floor_num) cdb_free(cdbfl); } else { if (floor_num == 0) { - strcpy(flbuf->f_name, "Main Floor"); + safestrncpy(flbuf->f_name, "Main Floor", + sizeof flbuf->f_name); flbuf->f_flags = F_INUSE; flbuf->f_ref_count = 3; } @@ -750,7 +751,7 @@ void usergoto(char *where, int display_result, int transiently, * we can skip the extra database fetch. */ if (where != NULL) { - strcpy(CC->room.QRname, where); + safestrncpy(CC->room.QRname, where, sizeof CC->room.QRname); getroom(&CC->room, where); } diff --git a/citadel/user_ops.c b/citadel/user_ops.c index cd8085cc2..4b9b00858 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -365,7 +365,8 @@ int CtdlLoginExistingUser(char *trythisname) if (((CC->nologin)) && (CC->user.axlevel < 6)) { return login_too_many_users; } else { - strcpy(CC->curr_user, CC->user.fullname); + safestrncpy(CC->curr_user, CC->user.fullname, + sizeof CC->curr_user); return login_ok; } } @@ -736,7 +737,7 @@ int create_user(char *newusername, int become_user) char mailboxname[ROOMNAMELEN]; uid_t uid; - strcpy(username, newusername); + safestrncpy(username, newusername, sizeof username); strproc(username); #ifdef ENABLE_AUTOLOGIN @@ -757,7 +758,7 @@ int create_user(char *newusername, int become_user) /* Go ahead and initialize a new user record */ memset(&usbuf, 0, sizeof(struct ctdluser)); - strcpy(usbuf.fullname, username); + safestrncpy(usbuf.fullname, username, sizeof usbuf.fullname); strcpy(usbuf.password, ""); usbuf.uid = uid; @@ -803,7 +804,7 @@ int create_user(char *newusername, int become_user) if (become_user) { /* Now become the user we just created */ memcpy(&CC->user, &usbuf, sizeof(struct ctdluser)); - strcpy(CC->curr_user, username); + safestrncpy(CC->curr_user, username, sizeof CC->curr_user); CC->logged_in = 1; /* Check to make sure we're still who we think we are */ -- 2.39.2