Merge pull request #1660 from rderooy/master

Inform on unexpected control characters in batch files
This commit is contained in:
Jonathan Campbell 2020-06-16 00:47:45 -07:00 committed by GitHub
commit 3aa68a251b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 13 deletions

View File

@ -4509,16 +4509,24 @@ private:
bool DetectMFMsectorPartition(Bit8u buf[], Bit32u fcsize, Bitu sizes[]) {
// This is used for plain MFM sector format as created by IMGMAKE
Bit8u starthead = 0;
Bit8u startsect = 0;
Bit16u startcyl = 0;
Bit16u endcyl = 0;
Bit8u ptype = 0; // Partition Type
Bit8u heads = 0;
Bit8u sectors = 0;
Bit16u pe1_size = host_readd(&buf[0x1fa]);
(void)ptype;//unused
if (pe1_size != 0) { // DOS 2.0-3.21 partition table
// It tries to find the first partition. Addressing is in CHS format.
/* Offset | Length | Description
* +0 | 1 byte | 80 hex = active, 00 = inactive
* +1 | 3 bytes | CHS of first sector in partition
* +4 | 1 byte | partition type
* +5 | 3 bytes | CHS of last sector in partition
* +8 | 4 bytes | LBA of first sector in partition
* +C | 4 bytes | Number of sectors in partition. 0 may mean, use LBA
*/
Bit8u starthead = 0; // start head of partition
Bit8u startsect = 0; // start sector of partition
Bit16u startcyl = 0; // start cylinder of partition
Bit8u ptype = 0; // Partition Type
Bit16u endcyl = 0; // end cylinder of partition
Bit8u heads = 0; // heads in partition
Bit8u sectors = 0; // sectors per track in partition
Bit32u pe1_size = host_readd(&buf[0x1fa]); // number of sectors in partition
if (pe1_size != 0) { // DOS 2.0-3.21 partition table, starting at 0x1EE
starthead = buf[0x1ef];
startsect = (buf[0x1f0] & 0x3fu) - 1u;
startcyl = (unsigned char)buf[0x1f1] | (unsigned int)((buf[0x1f0] & 0xc0) << 2u);
@ -4526,7 +4534,7 @@ private:
ptype = buf[0x1f2];
heads = buf[0x1f3] + 1u;
sectors = buf[0x1f4] & 0x3fu;
} else { // DOS 3.3+ partition table
} else { // DOS 3.3+ partition table, starting at 0x1BE
pe1_size = host_readd(&buf[0x1ca]);
if (pe1_size != 0) {
starthead = buf[0x1bf];

View File

@ -878,6 +878,8 @@ void SHELL_Init() {
MSG_Add("SHELL_CMD_HELP","If you want a list of all supported commands type \033[33;1mHELP /ALL\033[0m.\nA short list of the most often used commands:\n");
MSG_Add("SHELL_CMD_ECHO_ON","ECHO is on.\n");
MSG_Add("SHELL_CMD_ECHO_OFF","ECHO is off.\n");
MSG_Add("SHELL_ILLEGAL_CONTROL_CHARACTER",
"Unexpected control character: Dec %03u and Hex %#04x.\n");
MSG_Add("SHELL_ILLEGAL_SWITCH","Illegal switch: %s.\n");
MSG_Add("SHELL_MISSING_PARAMETER","Required parameter missing.\n");
MSG_Add("SHELL_CMD_CHDIR_ERROR","Unable to change to: %s.\n");

View File

@ -73,7 +73,10 @@ emptyline:
//So we continue reading till EOL/EOF
if (((cmd_write - temp) + 1) < (CMD_MAXLINE - 1))
*cmd_write++ = (char)c;
}
} else {
if (c != '\n' && c != '\r')
shell->WriteOut(MSG_Get("SHELL_ILLEGAL_CONTROL_CHARACTER"), c, c);
}
}
} while (c!='\n' && n);
*cmd_write=0;
@ -176,7 +179,10 @@ again:
if (c>31) {
if (((cmd_write - cmd_buffer) + 1) < (CMD_MAXLINE - 1))
*cmd_write++ = (char)c;
}
} else {
if (c != '\n' && c != '\r')
shell->WriteOut(MSG_Get("SHELL_ILLEGAL_CONTROL_CHARACTER"), c, c);
}
}
} while (c!='\n' && n);
*cmd_write++ = 0;