1,oracle的blob的InputStream读过一次后,再执行reset时就会报错。而上传的附件的inputstream就不会。
java.io.IOException: Mark invalid or stream not marked.
at oracle.jdbc.driver.OracleBlobInputStream.reset(OracleBlobInputStream.java:267)
2,
InputStream s = new BufferedInputStream(new FileInputStream("c:\\test"));
BufferedInputSream是可以使用mark及reset方法,使用上述的嵌套方法间接的使其它的stream也支持这些方法了。
3,以下代码有漏洞
在IO的编程中一定要保存基本流的引用
java.io.IOException: Mark invalid or stream not marked.
at oracle.jdbc.driver.OracleBlobInputStream.reset(OracleBlobInputStream.java:267)
2,
InputStream s = new BufferedInputStream(new FileInputStream("c:\\test"));
BufferedInputSream是可以使用mark及reset方法,使用上述的嵌套方法间接的使其它的stream也支持这些方法了。
3,以下代码有漏洞
public
Object readObject(File file)
{
Object o = null ;
if (file.exists())
{
FileInputStream fis = null ;
ObjectInputStream ois = null ;
try
{
fis = new FileInputStream(file);
ois = new ObjectInputStream(fis);
o = ois.readObject();
}
catch (Throwable e)
{
e.printStackTrace();
}
finally
{
if (fis != null )
{
try
{
fis.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
return o;
}
{
Object o = null ;
if (file.exists())
{
FileInputStream fis = null ;
ObjectInputStream ois = null ;
try
{
fis = new FileInputStream(file);
ois = new ObjectInputStream(fis);
o = ois.readObject();
}
catch (Throwable e)
{
e.printStackTrace();
}
finally
{
if (fis != null )
{
try
{
fis.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
return o;
}
在IO的编程中一定要保存基本流的引用
本文探讨了Oracle数据库中BLOB类型数据通过InputStream读取的问题,包括读取后的reset限制及如何利用BufferedInputStream实现mark和reset功能。此外,还讨论了一个关于文件读取和对象反序列化的潜在漏洞。
7157

被折叠的 条评论
为什么被折叠?



