[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: netcof

On Sat, Jan 01, 2000 at 03:22:21AM +0100, Goswin Brederlow wrote:
> "Sarel J. Botha" <sjb@dundee.lia.net> writes:
> Pretty Silly, close to get cought in my mass mail spam filter because
> of to many CCs. :)


> > I'm very happy with the parser. Just need to add some error-checking.
> > 
> > The interface changed a small bit, as it parses demand{} as well now. Check
> > net.conf for details.
> Whats net.conf? Did I miss something?

It's a parser for the network configuration system Rene Mayrhofer proposed
a while ago on debian-devel.

[ I know debian-admintool isn't the perfect list for this but it gets the
closest ]

> > parse_file() returns a pointer to a t_netconf which looks like this:
> > struct t_netconf {
> >   t_provider *demand;
> >   t_scheme *schemes;
> > }
> That should be changed asap to netconf_t to go along with size_t,
> off_t, pid_t, foo_t, bla_t and many more types that have the "_t" at
> the end and not at the front. I think its good style to keep it one way.

Well, t_ is actually for 'tree'. I think I'll just take the t_ away. (Don't
know what the _t in size_t is for)

> > If a word is longer than 80 chars it'll segfault.
> > How should I handle this? Just produce a warning or return NULL and an
> > error string?
> C or C++?
> If it is C, change it to C++ (use g++ instead of gcc is all that you
> need apart from removing any compile errors produced by that). :)

Yup, C. Don't know any C++.

> If you don't like that, "man snprintf", "man scanf". You have to tell
> C that your buffer you are reading to is only 80 chars long, which is
> a stupid limit. You should look for a scanf routine that works like
> snprintf or write yourself one that allocates and enlarges a C string
> (char[]) as it reads along and returns that.

(With scanf() you just use something like %80var -- just like printf() :)

Yea, I'll make it 1024. A large buffer isn't really needed as only a word
will be read into the buffer at a time. Everything after and up to a "
(quote) character counts as a word. So, what I meant is: If someone
accidentally does this in the conf file:

  address ";

instead of this:

  address "";

it's going to continue reading until it gets EOF or the buffer gets full. I
think I'll just return NULL and an error string as you can't really recover
from that.

> If its C++, how the fuck did you program that? Use the default string
> implementation and iostreams.

hehe :)

> PS: If you have problems with >80 chars strings you probably also have
> buffer overrun problems. Consider every literal number except 0, 1 and
> in some very rare cases 2 that you see in a program a bug or security
> risk which should be looked at closely. Of cause constants such as
> M_PI aren't ment here.

I have no idea what you mean here.

Sarel Botha

99 little bugs in the code, 99 bugs in the code,
          fix one bug, compile it again...
          101 little bugs in the code....

Reply to: