English 中文(简体)
如何在iOS中保护objectiveC字符串的解除锁定内存?
原标题:How to secure dealloc memory for objectiveC Strings in iOS?
  • 时间:2011-06-01 08:23:40
  •  标签:
  • iphone

I am pretty new in iOS development and I have the following question: In my code I have a UIViewController with a UIText field that will hold a password when user will type in the view. The password is used for authentication in front a server:

UItextField* txtPassword;
[myClass loginWithPassword:txtPassword.text];

使用后,我想确保内存中没有剩余的密码,这样攻击者就无法对iPhone执行内存转储并从中提取密码。

例如,在windows中,我可以使用SeucreZeroMemory函数来用零填充内存块。

iOS的最佳方式是什么?谁负责释放UItextField*字符串,这足够吗?

问题回答

What you want is really not needed, you don t need to write zeros over you allocated data to be sure that it is secure. The reason is that no one but you can access the memory and iOS uses address space randomization so even if it would be possible to get your memory, its hard to guess where your data is (and if one don t know where the data is, it is hard to guess what exactly the data is, luckily the RAM has no filesystem that helps in such a case). The second thing is, if you use [foo release] and you textfield gets deallocated in this process, the OS reclaims the memory. Now the OS will always fill new memory pages with zeroes before giving it to the asking process, so you don t have to fear that there is an malicious app that just allocates memory in the hope it finds the password this way.

ok, Release your object which store the password in your class by going into the dealloc methods. Or release when ever the use that object is finished.by writing this [object release]; I hope it will help you .





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签