由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Security版 - 问题 求教--在线等
相关主题
How to overwrite "/bin/login"?用 c 实现的字符串 permutation,求批评指点
how to know cable modem IP.昨天的F家店面
有用ZoneAlarm的兄弟吗?FB临门一脚挂了,那种郁闷悔恨的感觉.
linux 分区stratetyGoogle
一愁莫展!如何成功运行buffer overflow attack?求问下面这几行代码是做什么的,非常感谢!
about buffer overflow一个程序的小问题
c字符串内存分配问题奇怪的问题:关于一个简单的malloc()小程序 (转载)
请教一个fb面试问题问个《编程实践》(英文版)里面的问题
相关话题的讨论汇总
话题: buffer话题: size话题: eof话题: malloc话题: chars
进入Security版参与讨论
1 (共1页)
g*s
发帖数: 12
1
Here are two approaches to handling an input
file of arbitrary size:
A. Use a library or syscall that lets you determine the size
of the file. malloc a buffer to be that size. Then read
chars into the buffer until you hit EOF.
B. Malloc a buffer of a specific size. Read chars until
you hit that size, or EOF. If you fill the buffer,
use realloc to get a larger buffer.
From a security perspective, which is better? Why?
谢谢
p***y
发帖数: 27
2
A is not good i think,
If the size of the file changes after you determine the size of it,
the surplus part may overwrite the memory portion after the buffer
you allocated. And that portion may be a piece of code, the return addr
of a function call, etc.
Someone may write malicious code or address to get control of the host.

【在 g*s 的大作中提到】
: Here are two approaches to handling an input
: file of arbitrary size:
: A. Use a library or syscall that lets you determine the size
: of the file. malloc a buffer to be that size. Then read
: chars into the buffer until you hit EOF.
: B. Malloc a buffer of a specific size. Read chars until
: you hit that size, or EOF. If you fill the buffer,
: use realloc to get a larger buffer.
: From a security perspective, which is better? Why?
: 谢谢

1 (共1页)
进入Security版参与讨论
相关主题
问个《编程实践》(英文版)里面的问题一愁莫展!如何成功运行buffer overflow attack?
Amazon intern first phone interviewabout buffer overflow
A malloc/free question using C/C++c字符串内存分配问题
fb面试题【转】请教一个fb面试问题
How to overwrite "/bin/login"?用 c 实现的字符串 permutation,求批评指点
how to know cable modem IP.昨天的F家店面
有用ZoneAlarm的兄弟吗?FB临门一脚挂了,那种郁闷悔恨的感觉.
linux 分区stratetyGoogle
相关话题的讨论汇总
话题: buffer话题: size话题: eof话题: malloc话题: chars