Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 13 Jul 2015 11:19:16 +0800
From: Kai Zhao <>
Subject: Re: more robustness

Hi Alexander Cherepanov,

> If you are reading a whole file into memory (and I think we are not
> concerned with reading from pipes) then it's easier to get its size and
> allocate its full size in one go and read it in as one chunk. Then got
> through it replacing \n with 0 and saving addresses in a list. Or
> the list entirely.

Thanks for your advice. I will follow your idea. I will use mmap() to read
the whole file into memory. It will be more efficient.

> Why don't you use strcpy and other str* functions here and in similar
> cases?

Use str* functions is ok too. It's just my habit, maybe not good.

> In many cases you put a constant in a comparison on the left. It was
> useful to some degree some time ago (to catch = instead of == in
> conditions). But it's quite unintuitive and current compilers warn
> about most improper cases (if you don't have parenthesis around
> the comparison).
> IMHO it's better to move all constants to the right.

Yes, I will change those comparisons.

> And my personal preference is to drop checks "!= NULL" completely.
> But this is something for a debate.

Do you mean that use "if (pointer)" instead of "if (pointer != NULL)" ?
I am used to use the "if (pointer != NULL)", but most of the code in JtR
use "if (pointer)". I will change my style.



Content of type "text/html" skipped

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ