mirror of
https://github.com/tbamud/tbamud.git
synced 2025-09-21 21:40:49 +02:00
Fix string truncation warnings (Wstringop-truncation) (#53)
This commit is contained in:
parent
ad88f94a46
commit
14855c273a
5 changed files with 16 additions and 8 deletions
|
@ -1936,8 +1936,10 @@ void add_llog_entry(struct char_data *ch, int type) {
|
||||||
/* we didn't - make a new one */
|
/* we didn't - make a new one */
|
||||||
if(llast == NULL) { /* no entry found, add ..error if close! */
|
if(llast == NULL) { /* no entry found, add ..error if close! */
|
||||||
CREATE(llast,struct last_entry,1);
|
CREATE(llast,struct last_entry,1);
|
||||||
strncpy(llast->username,GET_NAME(ch),16);
|
strncpy(llast->username,GET_NAME(ch),15);
|
||||||
strncpy(llast->hostname,GET_HOST(ch),128);
|
strncpy(llast->hostname,GET_HOST(ch),127);
|
||||||
|
llast->username[15]='\0';
|
||||||
|
llast->hostname[127]='\0';
|
||||||
llast->idnum=GET_IDNUM(ch);
|
llast->idnum=GET_IDNUM(ch);
|
||||||
llast->punique=GET_PREF(ch);
|
llast->punique=GET_PREF(ch);
|
||||||
llast->time=time(0);
|
llast->time=time(0);
|
||||||
|
@ -2054,8 +2056,11 @@ ACMD(do_last)
|
||||||
num = atoi(arg);
|
num = atoi(arg);
|
||||||
if (num < 0)
|
if (num < 0)
|
||||||
num = 0;
|
num = 0;
|
||||||
} else
|
} else {
|
||||||
strncpy(name, arg, sizeof(name)-1);
|
strncpy(name, arg, sizeof(name)-1);
|
||||||
|
name[sizeof(name) - 1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
half_chop(argument, arg, argument);
|
half_chop(argument, arg, argument);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,9 +169,9 @@ ACMD(do_ban)
|
||||||
|
|
||||||
CREATE(ban_node, struct ban_list_element, 1);
|
CREATE(ban_node, struct ban_list_element, 1);
|
||||||
strncpy(ban_node->site, site, BANNED_SITE_LENGTH); /* strncpy: OK (b_n->site:BANNED_SITE_LENGTH+1) */
|
strncpy(ban_node->site, site, BANNED_SITE_LENGTH); /* strncpy: OK (b_n->site:BANNED_SITE_LENGTH+1) */
|
||||||
|
ban_node->site[BANNED_SITE_LENGTH] = '\0';
|
||||||
for (nextchar = ban_node->site; *nextchar; nextchar++)
|
for (nextchar = ban_node->site; *nextchar; nextchar++)
|
||||||
*nextchar = LOWER(*nextchar);
|
*nextchar = LOWER(*nextchar);
|
||||||
ban_node->site[BANNED_SITE_LENGTH] = '\0';
|
|
||||||
strncpy(ban_node->name, GET_NAME(ch), MAX_NAME_LENGTH); /* strncpy: OK (b_n->size:MAX_NAME_LENGTH+1) */
|
strncpy(ban_node->name, GET_NAME(ch), MAX_NAME_LENGTH); /* strncpy: OK (b_n->size:MAX_NAME_LENGTH+1) */
|
||||||
ban_node->name[MAX_NAME_LENGTH] = '\0';
|
ban_node->name[MAX_NAME_LENGTH] = '\0';
|
||||||
ban_node->date = time(0);
|
ban_node->date = time(0);
|
||||||
|
|
|
@ -1628,7 +1628,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
||||||
void var_subst(void *go, struct script_data *sc, trig_data *trig,
|
void var_subst(void *go, struct script_data *sc, trig_data *trig,
|
||||||
int type, char *line, char *buf)
|
int type, char *line, char *buf)
|
||||||
{
|
{
|
||||||
char tmp[MAX_INPUT_LENGTH], repl_str[MAX_INPUT_LENGTH];
|
char tmp[MAX_INPUT_LENGTH], repl_str[MAX_INPUT_LENGTH - 1];
|
||||||
char *var = NULL, *field = NULL, *p = NULL;
|
char *var = NULL, *field = NULL, *p = NULL;
|
||||||
char tmp2[MAX_INPUT_LENGTH];
|
char tmp2[MAX_INPUT_LENGTH];
|
||||||
char *subfield_p, subfield[MAX_INPUT_LENGTH];
|
char *subfield_p, subfield[MAX_INPUT_LENGTH];
|
||||||
|
@ -1722,4 +1722,5 @@ void var_subst(void *go, struct script_data *sc, trig_data *trig,
|
||||||
left -= len;
|
left -= len;
|
||||||
} /* else if *p .. */
|
} /* else if *p .. */
|
||||||
} /* while *p .. */
|
} /* while *p .. */
|
||||||
}
|
buf[sizeof(buf) - 1] = '\0';
|
||||||
|
}
|
||||||
|
|
|
@ -945,7 +945,8 @@ static int export_save_rooms(zone_rnum zrnum)
|
||||||
struct extra_descr_data *xdesc;
|
struct extra_descr_data *xdesc;
|
||||||
|
|
||||||
for (xdesc = room->ex_description; xdesc; xdesc = xdesc->next) {
|
for (xdesc = room->ex_description; xdesc; xdesc = xdesc->next) {
|
||||||
strncpy(buf, xdesc->description, sizeof(buf));
|
strncpy(buf, xdesc->description, sizeof(buf) - 1);
|
||||||
|
buf[sizeof(buf) - 1] = '\0';
|
||||||
strip_cr(buf);
|
strip_cr(buf);
|
||||||
fprintf(room_file, "E\n"
|
fprintf(room_file, "E\n"
|
||||||
"%s~\n"
|
"%s~\n"
|
||||||
|
|
|
@ -365,7 +365,8 @@ int save_rooms(zone_rnum rzone)
|
||||||
struct extra_descr_data *xdesc;
|
struct extra_descr_data *xdesc;
|
||||||
|
|
||||||
for (xdesc = room->ex_description; xdesc; xdesc = xdesc->next) {
|
for (xdesc = room->ex_description; xdesc; xdesc = xdesc->next) {
|
||||||
strncpy(buf, xdesc->description, sizeof(buf));
|
strncpy(buf, xdesc->description, sizeof(buf) - 1);
|
||||||
|
buf[sizeof(buf) - 1] = '\0';
|
||||||
strip_cr(buf);
|
strip_cr(buf);
|
||||||
fprintf(sf, "E\n"
|
fprintf(sf, "E\n"
|
||||||
"%s~\n"
|
"%s~\n"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue