首页> 外文会议>International symposium on NASA formal methods >Don't Miss the End: Preventing Unsafe End-of-File Comparisons
【24h】

Don't Miss the End: Preventing Unsafe End-of-File Comparisons

机译:不要错过终点:防止不安全的文件尾比较

获取原文

摘要

Reading from an InputStream or Reader in Java either returns the read byte/character or - 1 if the end-of-file (EOF) has been reached. To support the additional -1 as return value, the read methods return an int. For correct usage, the return value should be compared to -1 before being converted to byte or char. If the conversion was performed before the comparison, it can cause a read-until-EOF-loop to either exit prematurely or be stuck in an infinite loop. The SEI CERT Oracle Coding Standard for Java rule FIO08-J "Distinguish between characters or bytes read from a stream and -1" describes this issue in detail. This paper presents a type system that prevents unsafe EOF value comparisons statically and is implemented for Java using the Checker Framework. In an evaluation of 35 projects (9 million LOC) it detected 3 defects in production software, 8 bad coding practices, and no false positives. The overall annotation effort is very low. Overrides for the read methods needed to be annotated, requiring a total of 44 annotations. Additionally, 3 annotations for fields and method parameters needed to be added. To the best of our knowledge this is the first open source tool to prevent this security issue.
机译:从Java中的InputStream或Reader读取将返回读取的字节/字符,或者-如果已到达文件末尾(EOF),则返回-1。为了支持附加的-1作为返回值,read方法返回一个int值。为了正确使用,在将返回值转换为字节或字符之前,应将其与-1比较。如果转换是在比较之前进行的,则可能导致read-until-EOF循环过早退出或陷入无限循环。适用于Java的SEI CERT Oracle编码标准规则FIO08-J“区分从流读取的字符或字节与-1”详细描述了此问题。本文介绍了一种类型系统,该类型系统可静态防止进行不安全的EOF值比较,并使用Checker Framework在Java中实现该类型系统。在对35个项目(900万个LOC)的评估中,它检测到生产软件中的3个缺陷,8个不良的编码习惯以及无误报。整体注释工作非常少。需要对read方法的覆盖进行注释,总共需要44个注释。此外,还需要添加3个用于字段和方法参数的注释。据我们所知,这是防止该安全问题的第一个开源工具。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号