mirror of
https://github.com/tbamud/tbamud.git
synced 2026-04-30 04:41:51 +02:00
Compare commits
2 Commits
copilot/fi
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d0f3ecfbb | ||
|
|
2eb786ff0d |
@@ -415,7 +415,7 @@ void copyover_recover()
|
||||
|
||||
for (;;) {
|
||||
fOld = TRUE;
|
||||
if (fscanf(fp, "%d %ld %s %s %s\n", &desc, &pref, name, host, guiopt) != 5) {
|
||||
if (fscanf(fp, "%d %ld %511s %1023s %1023s\n", &desc, &pref, name, host, guiopt) != 5) {
|
||||
if(!feof(fp)) {
|
||||
if(ferror(fp))
|
||||
log("SYSERR: error reading copyover file %s: %s", COPYOVER_FILE, strerror(errno));
|
||||
|
||||
29
src/genolc.c
29
src/genolc.c
@@ -277,10 +277,7 @@ int sprintascii(char *out, bitvector_t bits)
|
||||
return j;
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
/* converts illegal filename chars into appropriate equivalents */
|
||||
static void fix_filename(const char *str, char *outbuf, size_t maxlen)
|
||||
{
|
||||
const char *in = str;
|
||||
@@ -288,17 +285,21 @@ static void fix_filename(const char *str, char *outbuf, size_t maxlen)
|
||||
int count = 0;
|
||||
|
||||
while (*in) {
|
||||
if (isalnum((unsigned char)*in) || *in == '_' || *in == '-' || *in == '.') {
|
||||
/* Safe characters kept as-is */
|
||||
*out++ = *in;
|
||||
if (++count == maxlen - 1) break;
|
||||
} else if (*in == ' ') {
|
||||
/* Spaces become underscores */
|
||||
*out++ = '_';
|
||||
if (++count == maxlen - 1) break;
|
||||
}
|
||||
/* All other characters, including shell metacharacters, are dropped */
|
||||
switch(*in) {
|
||||
case ' ': *out = '_'; out++; break;
|
||||
case '(': *out = '{'; out++; break;
|
||||
case ')': *out = '}'; out++; break;
|
||||
|
||||
/* skip the following */
|
||||
case '\'': break;
|
||||
case '"': break;
|
||||
|
||||
/* Legal character */
|
||||
default: *out = *in; out++;break;
|
||||
}
|
||||
in++;
|
||||
count++;
|
||||
if (count == maxlen - 1) break;
|
||||
}
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user