Skip to content
Snippets Groups Projects
Commit edaf5456 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Stdio.read_file() and Stdio.read_bytes() now only allow regular files.

Rev: lib/modules/Stdio.pmod:1.7
parent 87fd271d
No related branches found
No related tags found
No related merge requests found
......@@ -155,6 +155,15 @@ string read_file(string filename,void|int start,void|int len)
f=FILE();
if(!f->open(filename,"r")) return 0;
// Disallow devices and directories.
array st;
if (f->stat && (st = f->stat()) && (st[1] < 0)) {
throw(({ sprintf("Stdio.read_file(): File \"%s\" is not a regular file!\n",
filename),
backtrace()
}));
}
switch(query_num_arg())
{
case 1:
......@@ -187,6 +196,15 @@ string read_bytes(string filename,void|int start,void|int len)
if(!f->open(filename,"r"))
return 0;
// Disallow devices and directories.
array st;
if (f->stat && (st = f->stat()) && (st[1] < 0)) {
throw(({sprintf("Stdio.read_bytes(): File \"%s\" is not a regular file!\n",
filename),
backtrace()
}));
}
switch(query_num_arg())
{
case 1:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment