mirror of
https://github.com/tbamud/tbamud.git
synced 2026-04-30 04:41:51 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 80b77808f3 | |||
| c5bed0e141 |
+14
-15
@@ -277,7 +277,10 @@ int sprintascii(char *out, bitvector_t bits)
|
|||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* converts illegal filename chars into appropriate equivalents */
|
/* converts illegal filename chars into appropriate equivalents.
|
||||||
|
* Uses an allowlist: alphanumerics, underscore, hyphen, and dot are kept;
|
||||||
|
* spaces are converted to underscores; all other characters (including shell
|
||||||
|
* metacharacters such as ; | & ` $ > < \n) are silently dropped. */
|
||||||
static void fix_filename(const char *str, char *outbuf, size_t maxlen)
|
static void fix_filename(const char *str, char *outbuf, size_t maxlen)
|
||||||
{
|
{
|
||||||
const char *in = str;
|
const char *in = str;
|
||||||
@@ -285,21 +288,17 @@ static void fix_filename(const char *str, char *outbuf, size_t maxlen)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
while (*in) {
|
while (*in) {
|
||||||
switch(*in) {
|
if (isalnum((unsigned char)*in) || *in == '_' || *in == '-' || *in == '.') {
|
||||||
case ' ': *out = '_'; out++; break;
|
/* Safe characters kept as-is */
|
||||||
case '(': *out = '{'; out++; break;
|
*out++ = *in;
|
||||||
case ')': *out = '}'; out++; break;
|
if (++count == maxlen - 1) break;
|
||||||
|
} else if (*in == ' ') {
|
||||||
/* skip the following */
|
/* Spaces become underscores */
|
||||||
case '\'': break;
|
*out++ = '_';
|
||||||
case '"': break;
|
if (++count == maxlen - 1) break;
|
||||||
|
}
|
||||||
/* Legal character */
|
/* All other characters, including shell metacharacters, are dropped */
|
||||||
default: *out = *in; out++;break;
|
|
||||||
}
|
|
||||||
in++;
|
in++;
|
||||||
count++;
|
|
||||||
if (count == maxlen - 1) break;
|
|
||||||
}
|
}
|
||||||
*out = '\0';
|
*out = '\0';
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -405,7 +405,7 @@ int load_char(const char *name, struct char_data *ch)
|
|||||||
|
|
||||||
case 'P':
|
case 'P':
|
||||||
if (!strcmp(tag, "Page")) GET_PAGE_LENGTH(ch) = atoi(line);
|
if (!strcmp(tag, "Page")) GET_PAGE_LENGTH(ch) = atoi(line);
|
||||||
else if (!strcmp(tag, "Pass")) { strncpy(GET_PASSWD(ch), line, MAX_PWD_LENGTH); GET_PASSWD(ch)[MAX_PWD_LENGTH] = '\0'; }
|
else if (!strcmp(tag, "Pass")) strcpy(GET_PASSWD(ch), line);
|
||||||
else if (!strcmp(tag, "Plyd")) ch->player.time.played = atoi(line);
|
else if (!strcmp(tag, "Plyd")) ch->player.time.played = atoi(line);
|
||||||
else if (!strcmp(tag, "PfIn")) POOFIN(ch) = strdup(line);
|
else if (!strcmp(tag, "PfIn")) POOFIN(ch) = strdup(line);
|
||||||
else if (!strcmp(tag, "PfOt")) POOFOUT(ch) = strdup(line);
|
else if (!strcmp(tag, "PfOt")) POOFOUT(ch) = strdup(line);
|
||||||
|
|||||||
Reference in New Issue
Block a user