Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Qmail: users

qmail code error

 

 

Qmail users RSS feed   Index | Next | Previous | View Threaded


frowtster at gmail

Mar 4, 2009, 8:28 PM

Post #1 of 4 (1258 views)
Permalink
qmail code error

I found a qmail code error..probably.

qmail-1.0.3
In env.c:113, &environ => environ

But, it is not a real bug. Because, that line is not called.
How about do you think?


kyle-qmail at memoryhole

Mar 4, 2009, 10:30 PM

Post #2 of 4 (1160 views)
Permalink
Re: qmail code error [In reply to]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday, March 5 at 01:28 PM, quoth Y.K. Choi:
>I found a qmail code error..probably.
>
>qmail-1.0.3
>In env.c:113, &environ => environ

In qmail-1.03, line 113 or env.c is:

}

The file itself is 113 lines long.

It sounds like you've found a bug in a patch that you use. Where did
you get your source?

~Kyle
- --
Truth springs from argument amongst friends.
-- David Hume
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!

iEYEARECAAYFAkmvcW0ACgkQBkIOoMqOI16RpQCfYSQE6gv6PFzTWCGtyyMGYP6m
xd4AoJhSG9yyjI+spS4nHXwVNCpgVYsD
=1Nfm
-----END PGP SIGNATURE-----


frowtster at gmail

Mar 5, 2009, 4:12 AM

Post #3 of 4 (1165 views)
Permalink
Re: qmail code error [In reply to]

Oh.
Thanks for your correction...

env.c:56, &environ => environ

On Thu, Mar 5, 2009 at 3:30 PM, Kyle Wheeler <kyle-qmail [at] memoryhole>wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Thursday, March 5 at 01:28 PM, quoth Y.K. Choi:
> >I found a qmail code error..probably.
> >
> >qmail-1.0.3
> >In env.c:113, &environ => environ
>
> In qmail-1.03, line 113 or env.c is:
>
> }
>
> The file itself is 113 lines long.
>
> It sounds like you've found a bug in a patch that you use. Where did
> you get your source?
>
> ~Kyle
> - --
> Truth springs from argument amongst friends.
> -- David Hume
> -----BEGIN PGP SIGNATURE-----
> Comment: Thank you for using encryption!
>
> iEYEARECAAYFAkmvcW0ACgkQBkIOoMqOI16RpQCfYSQE6gv6PFzTWCGtyyMGYP6m
> xd4AoJhSG9yyjI+spS4nHXwVNCpgVYsD
> =1Nfm
> -----END PGP SIGNATURE-----
>


kyle-qmail at memoryhole

Mar 5, 2009, 8:58 AM

Post #4 of 4 (1152 views)
Permalink
Re: qmail code error [In reply to]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday, March 5 at 09:12 PM, quoth Y.K. Choi:
>Oh.
>Thanks for your correction...
>
>env.c:56, &environ => environ

Okay, line 56 is:

if (!alloc_re(&environ,(en + 1) * sizeof(char *),(ea + 1) * sizeof(char*))

So, if I understand you, you're suggesting that it *should be:

if (!alloc_re(environ,...

right?

I can see why you would say that, but let's investigate more closely.
What does alloc_re do?

Well, it assumes it's been passed an array of pointers (a char**), and
what it does is change the size of the first element of that array.
So, if it's called on environ, it will change the size of the array
pointed to by environ[0], whereas if it's called on &environ, it will
instead change the size of the environ array itself (the expression
&environ essentially produces a single-element array of pointers to
the variable environ---we're resizing (&environ)[0]). Does that make
sense?

Let's take a moment to examine environ. It is a list of all the
environment variables. For example, environ[0] may be the string
"SHELL=/bin/sh" and environ[1] may be the string "TZ=US/Eastern", and
so on.

So what is the env_add() function trying to do? It's trying to ADD an
environment variable to the environment. In order to do that, what
does it need to do? Obviously, it needs to make the environ array one
entry longer, and then put the new environment variable (s, in this
case) into that new entry.

And resize the environ array is precisely what the env_add() function
does does, but it uses the alloc_re() function to do so.

So, you're correct that the data types don't match, but the result is
the correct behavior. So, it's not a bug, even if it is slightly
confusing. It's probably even an intentional choice, to avoid needing
to write a function that's identical to alloc_re() but that has
different argument types.

~Kyle
- --
Arguing with an engineer is like wrestling with a pig in mud, after a
while you realize the pig is enjoying it.
-- Unknown
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!

iEYEARECAAYFAkmwBJgACgkQBkIOoMqOI14IkgCfSFYa1AuefwQBfzZ+4eh3LQ7N
HVsAn1NI7GQVAOCpi8UMgiKBycx60AiU
=luTE
-----END PGP SIGNATURE-----

Qmail users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.