473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Memory Management Problem?

Forgive my rather wide posting of this note, but I was uncertain of where I
would find the best help.

I am working on a class that is basically providing a secure location for
name/value pairs to be stored by the application. I am using TripleDES
encryption and having a very odd problem that appears to be related to a
memory management issue in the CLR. I have the 1.1 .NET Framework installed
and I am using VS.NET 2002.

I have a class whose definition begins like so:

Public Class cSecureConfigFile
' internal constants
Private Const BASE_XML As String = "XML crap here"
' internal objects
Private des As TripleDESCryptoServiceProvider = New
TripleDESCryptoServiceProvider()
Private md5 As New MD5CryptoServiceProvider()
Private xmlDoc As New XmlDocument()
Private ReadOnly fileName As String = Environment.CurrentDirectory &
"\cfg.bin"
Private ReadOnly key() As Byte = {<24 bytes go here>}
Private ReadOnly iv() As Byte = {8, 7, 6, 5, 4, 3, 2, 1}
The first time I run, if there is no file, I create one. Then I save it in
an encrypted manner. This works fine.

The second time I run, I decrypt the file just fine. Then, as soon as I
instantiate a new memory stream (xmlStream) and make the following call:

xmlDoc.Save(xmlStream)

my encryption vector (iv) is "flushed" (all bytes set to 0). Since the
variable is defined ReadOnly and I am not doing anything even remotely
related to the TDES object, I am thinking that the unused, tail-end of the
memory stream being used by xmlDoc is overwriting the vector array. As a
result, when I decrypt my file the next go around, the first 8 bytes are
screwed up.

As a test, I moved the declaration of the key and vector arrays to be inside
of the encryption function, and it all works flawlessly.

Is there something I am missing here, or does it look (as I suspect) like
the CLR is allowing a memory stream to overwrite an existing, used block of
memory?

Tony
Jul 21 '05 #1
1 1310
In article <Oa*************@TK2MSFTNGP11.phx.gbl>, Tony Selke wrote:
Forgive my rather wide posting of this note, but I was uncertain of where I
would find the best help.

I am working on a class that is basically providing a secure location for
name/value pairs to be stored by the application. I am using TripleDES
encryption and having a very odd problem that appears to be related to a
memory management issue in the CLR. I have the 1.1 .NET Framework installed
and I am using VS.NET 2002.


If your using VS.NET 2002, then your still using the 1.0 framework -
even if the 1.1 is installed. With out doing alot of analysis, if this
is a framework bug, you may want to recompile it using the 1.1
framework, which means either installing VS.NET 2003 or compiling it by
hand from the command line.

--
Tom Shelton
MVP [Visual Basic]
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Tron Thomas | last post by:
Given the following information about memory management in C++: ----- The c-runtime dynamic memory manager (and most other commercial memory managers) has issues with fragmentation similar to a...
4
by: Franklin Lee | last post by:
Hi All, I use new to allocate some memory,even I doesn't use delete to release them. When my Application exit, OS will release them. Am I right? If I'm right, how about Thread especally on...
17
by: ~Gee | last post by:
Hi Folks! Please see the program below: 1 #include<iostream> 2 #include<list> 3 #include <unistd.h> 4 using namespace std; 5 int main() 6 { 7 {
2
by: DANIEL BEAULIEU J | last post by:
Basically i am a student taking an operating systems course which is c++ intensive. Familiar with Java, and so not so familiar with memory management. Looking for suggestions of exercises or web...
9
by: Mike P | last post by:
I know everything about reference counting and making sure you don't have large objects lying around. I have also profiled my app with multiple tools. I know about the fact GC collects memory but...
3
by: beattie.stuart | last post by:
I think I've found a memory leak trying to use the system.management.ManagementObject, but it could be my programming skills so I'd appreciate some advice. I've writing a monitoring routine that...
94
by: smnoff | last post by:
I have searched the internet for malloc and dynamic malloc; however, I still don't know or readily see what is general way to allocate memory to char * variable that I want to assign the substring...
5
by: RobbGMelenyk | last post by:
I've got a Windows Service written in C# that is having some unfortunate memory issues. I've been working with .NET MemProfiler and AllocationProfiler. But you don't have to use those programs to...
3
by: Jim Land | last post by:
Jack Slocum claims here http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript- memory-leaks/ that "almost every site you visit that uses JavaScript is leaking memory". ...
5
by: kumarmdb2 | last post by:
Hi guys, For last few days we are getting out of private memory error. We have a development environment. We tried to figure out the problem but we believe that it might be related to the OS...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.