Re: [Sablevm-developer] Config File Parsing (Done)
Brought to you by:
egagnon
From: Brent F. <bfu...@de...> - 2000-12-09 07:24:42
|
On Sat, Dec 09, 2000 at 12:42:16AM -0500, Etienne M. Gagnon wrote: > Hi Brent! > > Sorry for taking some time to reply. I was partly in bed, fighting a > popular Winter virus:-( [By the way, it is quite cold here these days: > the maximum today was -15 celcius!] > Brrr! I hate to be cruel, but here in Ventura California the low has been about 45 F (evening), and around 65 F (Daylight). (I'm wearing shorts right now.) > Thanks a lot for your contribution. I have looked at it quickly, and it > seems mostly good. > Great! > By the way, I forgot to tell you: to indent your code, simply type > 'make indent' in the root directory, and it will indent all your code > according to the GNU standard. On Debian, make sure to 'apt-get install > indent' first. > Already had it, but I have never worked it into the build system like this before. What a great idea! My indent settings are different from your in my editor, so it's nice to be able to get things in synch. > There are a few points, though [I know, I am very picky;-)]: > 1- You use hard coded array lenghts, this can cause all sorts of > problems. (Ever heard about buffer overflow exploits?) Yes! That's why I use strnlen/strncpy everywhere. But you are quite correct. I've modified the code to have no limits on the size of the array or the length of the strings. I have tested it with a file of 18 options, but there may be some nastiness I've missed. Let's all test it out... :-) > 2- You are using a non ISO/POSIX function `getline'. I have fixed > configure.in so that this breaks the build, which is a good thing, if we > want SableVM to remain portable. > Ack. I did think about this, but I read in the GNU C Library manual that getline is recommended since it is safer, because it does a realloc on the string buffer if it's not long enough. However, it's not portable so I've reworked the code to use "fgets", which should be ANSI compliant according to my "System V" programming guide. Please let me know if this still causes trouble. > > So, if you could help me fixing these two things, it would be great. > [No more MAXPATHLENGTH, or 12 (!!!) constants], and replace the call to > getline() by something equivalent that only uses ISO/POSIX library > calls. [Preference going to pure ISO library]. > Done! -Brent |