mirror of
https://github.com/tbamud/tbamud.git
synced 2025-12-28 04:58:48 +01:00
Fixes for w-format-truncation. Also, export of zones work again on linux
This commit is contained in:
parent
b028d60749
commit
29f19f9ce5
8 changed files with 60 additions and 34 deletions
|
|
@ -144,7 +144,7 @@ static int is_tell_ok(struct char_data *ch, struct char_data *vict)
|
|||
ACMD(do_tell)
|
||||
{
|
||||
struct char_data *vict = NULL;
|
||||
char buf[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH];
|
||||
char buf[MAX_INPUT_LENGTH + 25], buf2[MAX_INPUT_LENGTH]; // +25 to make room for constants
|
||||
|
||||
half_chop(argument, buf, buf2);
|
||||
|
||||
|
|
@ -397,7 +397,7 @@ ACMD(do_gen_comm)
|
|||
{
|
||||
struct descriptor_data *i;
|
||||
char color_on[24];
|
||||
char buf1[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH], *msg;
|
||||
char buf1[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH + 50], *msg; // + 50 to make room for color codes
|
||||
bool emoting = FALSE;
|
||||
|
||||
/* Array of flags which must _not_ be set in order for comm to be heard. */
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ SPECIAL(gen_board)
|
|||
int board_write_message(int board_type, struct char_data *ch, char *arg, struct obj_data *board)
|
||||
{
|
||||
time_t ct;
|
||||
char buf[MAX_INPUT_LENGTH], buf2[MAX_NAME_LENGTH + 3], tmstr[MAX_STRING_LENGTH];
|
||||
char buf[MAX_INPUT_LENGTH], buf2[MAX_NAME_LENGTH + 3], tmstr[100];
|
||||
|
||||
if (GET_LEVEL(ch) < WRITE_LVL(board_type)) {
|
||||
send_to_char(ch, "You are not holy enough to write on this board.\r\n");
|
||||
|
|
|
|||
4
src/db.c
4
src/db.c
|
|
@ -936,7 +936,7 @@ void index_boot(int mode)
|
|||
const char *index_filename, *prefix = NULL; /* NULL or egcs 1.1 complains */
|
||||
FILE *db_index, *db_file;
|
||||
int line_number, rec_count = 0, size[2];
|
||||
char buf2[PATH_MAX], buf1[MAX_STRING_LENGTH];
|
||||
char buf2[PATH_MAX], buf1[PATH_MAX - 100]; // - 100 to make room for prefix
|
||||
|
||||
switch (mode) {
|
||||
case DB_BOOT_WLD:
|
||||
|
|
@ -3900,7 +3900,7 @@ static void load_default_config( void )
|
|||
void load_config( void )
|
||||
{
|
||||
FILE *fl;
|
||||
char line[MAX_STRING_LENGTH];
|
||||
char line[READ_SIZE - 2]; // to make sure there's room for readding \r\n
|
||||
char tag[MAX_INPUT_LENGTH];
|
||||
int num;
|
||||
char buf[MAX_INPUT_LENGTH];
|
||||
|
|
|
|||
|
|
@ -1968,7 +1968,7 @@ static void makeuid_var(void *go, struct script_data *sc, trig_data *trig,
|
|||
{
|
||||
char junk[MAX_INPUT_LENGTH], varname[MAX_INPUT_LENGTH];
|
||||
char arg[MAX_INPUT_LENGTH], name[MAX_INPUT_LENGTH];
|
||||
char uid[MAX_INPUT_LENGTH];
|
||||
char uid[MAX_INPUT_LENGTH + 1]; // to make room for UID_CHAR
|
||||
|
||||
*uid = '\0';
|
||||
half_chop(cmd, junk, cmd); /* makeuid */
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
int type, char *line, char *buf)
|
||||
{
|
||||
char tmp[MAX_INPUT_LENGTH], repl_str[MAX_INPUT_LENGTH - 1];
|
||||
char tmp[MAX_INPUT_LENGTH], repl_str[MAX_INPUT_LENGTH - 20]; // - 20 to make room for "eval tmpvr "
|
||||
char *var = NULL, *field = NULL, *p = NULL;
|
||||
char tmp2[MAX_INPUT_LENGTH];
|
||||
char *subfield_p, subfield[MAX_INPUT_LENGTH];
|
||||
|
|
|
|||
74
src/genolc.c
74
src/genolc.c
|
|
@ -278,39 +278,44 @@ int sprintascii(char *out, bitvector_t bits)
|
|||
}
|
||||
|
||||
/* converts illegal filename chars into appropriate equivalents */
|
||||
static char *fix_filename(char *str)
|
||||
static void fix_filename(const char *str, char *outbuf, size_t maxlen)
|
||||
{
|
||||
static char good_file_name[MAX_STRING_LENGTH];
|
||||
char *cindex = good_file_name;
|
||||
|
||||
while(*str) {
|
||||
switch(*str) {
|
||||
case ' ': *cindex = '_'; cindex++; break;
|
||||
case '(': *cindex = '{'; cindex++; break;
|
||||
case ')': *cindex = '}'; cindex++; break;
|
||||
const char *in = str;
|
||||
char *out = outbuf;
|
||||
int count = 0;
|
||||
|
||||
while (*in) {
|
||||
switch(*in) {
|
||||
case ' ': *out = '_'; out++; break;
|
||||
case '(': *out = '{'; out++; break;
|
||||
case ')': *out = '}'; out++; break;
|
||||
|
||||
/* skip the following */
|
||||
case '\'': break;
|
||||
case '"': break;
|
||||
|
||||
/* Legal character */
|
||||
default: *cindex = *str; cindex++;break;
|
||||
default: *out = *in; out++;break;
|
||||
}
|
||||
str++;
|
||||
}
|
||||
*cindex = '\0';
|
||||
|
||||
return good_file_name;
|
||||
in++;
|
||||
count++;
|
||||
if (count == maxlen - 1) break;
|
||||
}
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
/* Export command by Kyle */
|
||||
ACMD(do_export_zone)
|
||||
{
|
||||
#ifdef CIRCLE_WINDOWS
|
||||
/* tar and gzip are usually not available */
|
||||
send_to_char(ch, "Sorry, that is not available in the windows port.\r\n");
|
||||
#else /* all other configurations */
|
||||
zone_rnum zrnum;
|
||||
zone_vnum zvnum;
|
||||
char sysbuf[MAX_INPUT_LENGTH];
|
||||
char zone_name[MAX_INPUT_LENGTH], *f;
|
||||
int success;
|
||||
char zone_name[READ_SIZE], fixed_file_name[READ_SIZE];
|
||||
int success, errorcode = 0;
|
||||
|
||||
/* system command locations are relative to where the binary IS, not where it
|
||||
* was run from, thus we act like we are in the bin folder, because we are*/
|
||||
|
|
@ -336,9 +341,14 @@ ACMD(do_export_zone)
|
|||
/* If we fail, it might just be because the directory didn't exist. Can't
|
||||
* hurt to try again. Do it silently though ( no logs ). */
|
||||
if (!export_info_file(zrnum)) {
|
||||
sprintf(sysbuf, "mkdir %s", path);
|
||||
sprintf(sysbuf, "mkdir %s", path);
|
||||
errorcode = system(sysbuf);
|
||||
}
|
||||
|
||||
if (errorcode) {
|
||||
send_to_char(ch, "Failed to create export directory.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(success = export_info_file(zrnum)))
|
||||
send_to_char(ch, "Info file not saved!\r\n");
|
||||
if (!(success = export_save_shops(zrnum)))
|
||||
|
|
@ -363,18 +373,34 @@ ACMD(do_export_zone)
|
|||
return;
|
||||
}
|
||||
/* Make sure the name of the zone doesn't make the filename illegal. */
|
||||
f = fix_filename(zone_name);
|
||||
fix_filename(zone_name, fixed_file_name, sizeof(fixed_file_name));
|
||||
|
||||
/* Remove the old copy. */
|
||||
snprintf(sysbuf, MAX_INPUT_LENGTH, "rm %s%s.tar.gz", path, f);
|
||||
snprintf(sysbuf, sizeof(sysbuf), "rm %s%s.tar.gz", path, fixed_file_name);
|
||||
errorcode = system(sysbuf);
|
||||
if (errorcode) {
|
||||
send_to_char(ch, "Failed to delete previous zip file. This is usually benign.\r\n");
|
||||
}
|
||||
|
||||
|
||||
/* Tar the new copy. */
|
||||
snprintf(sysbuf, MAX_INPUT_LENGTH, "tar -cf %s%s.tar %sqq.info %sqq.wld %sqq.zon %sqq.mob %sqq.obj %sqq.trg %sqq.shp", path, f, path, path, path, path, path, path, path);
|
||||
snprintf(sysbuf, sizeof(sysbuf), "tar -cf %s%s.tar %sqq.info %sqq.wld %sqq.zon %sqq.mob %sqq.obj %sqq.trg %sqq.shp", path, fixed_file_name, path, path, path, path, path, path, path);
|
||||
errorcode = system(sysbuf);
|
||||
if (errorcode) {
|
||||
send_to_char(ch, "Failed to tar files.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Gzip it. */
|
||||
snprintf(sysbuf, MAX_INPUT_LENGTH, "gzip %s%s.tar", path, f);
|
||||
snprintf(sysbuf, sizeof(sysbuf), "gzip %s%s.tar", path, fixed_file_name);
|
||||
errorcode = system(sysbuf);
|
||||
if (errorcode) {
|
||||
send_to_char(ch, "Failed to gzip tar file.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
send_to_char(ch, "Files tar'ed to \"%s%s.tar.gz\"\r\n", path, f);
|
||||
send_to_char(ch, "Files tar'ed to \"%s%s.tar.gz\"\r\n", path, fixed_file_name);
|
||||
#endif /* platform specific part */
|
||||
}
|
||||
|
||||
static int export_info_file(zone_rnum zrnum)
|
||||
|
|
|
|||
|
|
@ -1177,7 +1177,7 @@ obj_save_data *objsave_parse_objects(FILE *fl)
|
|||
|
||||
static int Crash_load_objs(struct char_data *ch) {
|
||||
FILE *fl;
|
||||
char filename[MAX_STRING_LENGTH];
|
||||
char filename[PATH_MAX];
|
||||
char line[READ_SIZE];
|
||||
char buf[MAX_STRING_LENGTH];
|
||||
char str[64];
|
||||
|
|
|
|||
|
|
@ -474,7 +474,7 @@ static int sell_price(struct obj_data *obj, int shop_nr, struct char_data *keepe
|
|||
|
||||
static void shopping_buy(char *arg, struct char_data *ch, struct char_data *keeper, int shop_nr)
|
||||
{
|
||||
char tempstr[MAX_INPUT_LENGTH], tempbuf[MAX_INPUT_LENGTH];
|
||||
char tempstr[MAX_INPUT_LENGTH - 10], tempbuf[MAX_INPUT_LENGTH];
|
||||
struct obj_data *obj, *last_obj = NULL;
|
||||
int goldamt = 0, buynum, bought = 0;
|
||||
|
||||
|
|
@ -739,7 +739,7 @@ static void sort_keeper_objs(struct char_data *keeper, int shop_nr)
|
|||
|
||||
static void shopping_sell(char *arg, struct char_data *ch, struct char_data *keeper, int shop_nr)
|
||||
{
|
||||
char tempstr[MAX_INPUT_LENGTH], name[MAX_INPUT_LENGTH], tempbuf[MAX_INPUT_LENGTH];
|
||||
char tempstr[MAX_INPUT_LENGTH - 10], name[MAX_INPUT_LENGTH], tempbuf[MAX_INPUT_LENGTH]; // - 10 to make room for constants in format
|
||||
struct obj_data *obj;
|
||||
int sellnum, sold = 0, goldamt = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue