mirror of https://github.com/FDOS/kernel.git
fix read calls to detect error, from Eric Auer (brought to his attention by Brad?)
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1177 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
87dc4b08d5
commit
1420e23819
|
@ -618,7 +618,8 @@ static void DoConfig_(void)
|
||||||
nCfgLine++;
|
nCfgLine++;
|
||||||
for (q = szLine;;)
|
for (q = szLine;;)
|
||||||
{
|
{
|
||||||
if (read(nFileDesc, q, 1) <= 0 || *q == EOF)
|
/* if EOF already found, error reading, or EOF char read then we're done */
|
||||||
|
if (read(nFileDesc, q, 1) != 1 || *q == EOF)
|
||||||
{
|
{
|
||||||
done++;
|
done++;
|
||||||
break;
|
break;
|
||||||
|
@ -1187,9 +1188,9 @@ STATIC void LoadCountryInfo(PCStr filename, int ccode, int cpage)
|
||||||
printf("%s not found\n", filename);
|
printf("%s not found\n", filename);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (read(fd, &header, sizeof(header)) < sizeof(header))
|
if (read(fd, &header, sizeof(header)) != sizeof(header))
|
||||||
{
|
{
|
||||||
printf("Can't read %s\n", filename);
|
printf("Error reading %s\n", filename);
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
if (memcmp(header.name, "\377COUNTRY", sizeof(header.name)))
|
if (memcmp(header.name, "\377COUNTRY", sizeof(header.name)))
|
||||||
|
@ -1198,19 +1199,19 @@ err:printf("%s has invalid format\n", filename);
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
if (lseek(fd, header.offset) == 0xffffffffL
|
if (lseek(fd, header.offset) == 0xffffffffL
|
||||||
|| read(fd, &entries, sizeof(entries)) < sizeof(entries))
|
|| read(fd, &entries, sizeof(entries)) != sizeof(entries))
|
||||||
goto err;
|
goto err;
|
||||||
for (i = 0; i < entries; i++)
|
for (i = 0; i < entries; i++)
|
||||||
{
|
{
|
||||||
if (read(fd, &entry, sizeof(entry)) < sizeof(entry) || entry.length != 12)
|
if (read(fd, &entry, sizeof(entry)) != sizeof(entry) || entry.length != 12)
|
||||||
goto err;
|
goto err;
|
||||||
if (entry.country != ccode || entry.codepage != cpage && cpage)
|
if (entry.country != ccode || entry.codepage != cpage && cpage)
|
||||||
continue;
|
continue;
|
||||||
if (lseek(fd, entry.offset) == 0xffffffffL
|
if (lseek(fd, entry.offset) == 0xffffffffL
|
||||||
|| read(fd, &count, sizeof(count)) < sizeof(count)
|
|| read(fd, &count, sizeof(count)) != sizeof(count)
|
||||||
|| count > LENGTH(hdr)
|
|| count > LENGTH(hdr)
|
||||||
|| read(fd, &hdr, sizeof(struct subf_hdr) * count)
|
|| read(fd, &hdr, sizeof(struct subf_hdr) * count)
|
||||||
< sizeof(struct subf_hdr) * count)
|
!= sizeof(struct subf_hdr) * count)
|
||||||
goto err;
|
goto err;
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -1219,10 +1220,10 @@ err:printf("%s has invalid format\n", filename);
|
||||||
if (hdr[i].id < 1 || hdr[i].id > 6 || hdr[i].id == 3)
|
if (hdr[i].id < 1 || hdr[i].id > 6 || hdr[i].id == 3)
|
||||||
continue;
|
continue;
|
||||||
if (lseek(fd, hdr[i].offset) == 0xffffffffL
|
if (lseek(fd, hdr[i].offset) == 0xffffffffL
|
||||||
|| read(fd, &subf_data, 10) < 10
|
|| read(fd, &subf_data, 10) != 10
|
||||||
|| memcmp(subf_data.signature, table[hdr[i].id].sig, 8) && (hdr[i].id !=4
|
|| memcmp(subf_data.signature, table[hdr[i].id].sig, 8) && (hdr[i].id !=4
|
||||||
|| memcmp(subf_data.signature, table[2].sig, 8)) /* UCASE for FUCASE ^*/
|
|| memcmp(subf_data.signature, table[2].sig, 8)) /* UCASE for FUCASE ^*/
|
||||||
|| read(fd, subf_data.buffer, subf_data.length) < subf_data.length)
|
|| read(fd, subf_data.buffer, subf_data.length) != subf_data.length)
|
||||||
goto err;
|
goto err;
|
||||||
if (hdr[i].id == 1)
|
if (hdr[i].id == 1)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue