On Wed, Dec 19, 2007 at 10:39:11AM +0000, Gerrit Pape wrote:
> From: Steve Langasek <[EMAIL PROTECTED]>
> 
> dash dies on sparc with a SIGBUS due to an arithmetic error introduced
> with commit 03b4958, this patch fixes it.

Thanks for catching this! I really hate gcc's void * arithmetic
extension.

>       /* Reserve one extra spot at the front for shellexec. */
> -     argv = nargv = stalloc(sizeof (char *) * (argc + 2)) + 1;
> +     argv = nargv = ((char **)stalloc(sizeof (char *) * (argc + 2))) + 1;

BTW, I've modified this slightly to remove the need to cast.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[EMAIL PROTECTED]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
commit 745e09faa22eb06e00588b198210b302c860a988
Author: Steve Langasek <[EMAIL PROTECTED]>
Date:   Sun Dec 23 11:02:26 2007 +0800

    [EVAL] Fix bad pointer arithmetic in evalcommand
    
    dash dies on sparc with a SIGBUS due to an arithmetic error introduced
    with commit 03b4958, this patch fixes it.
    ---
    
    > Hi Gerrit,
    >
    > dash 0.5.4-3 dies on sparc with a SIGBUS due to an arithmetic error
    > introduced with the patch
    > 0030-EXEC-Fixed-execing-of-scripts-with-no-hash-bang.diff.  The
    > attached
    > patch fixes the problem.
    
    Signed-off-by: Herbert Xu <[EMAIL PROTECTED]>

diff --git a/ChangeLog b/ChangeLog
index de37261..e72849c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-12-23  Steve Langasek <[EMAIL PROTECTED]>
+
+       * Fixed bad pointer arithmetic in evalcommand.
+
 2007-11-11  Herbert Xu <[EMAIL PROTECTED]>
 
        * Removed noexpand/length check on eofmark.
diff --git a/src/eval.c b/src/eval.c
index a8feaa0..77291b4 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -722,7 +722,8 @@ evalcommand(union node *cmd, int flags)
        }
 
        /* Reserve one extra spot at the front for shellexec. */
-       argv = nargv = stalloc(sizeof (char *) * (argc + 2)) + 1;
+       nargv = stalloc(sizeof (char *) * (argc + 2));
+       argv = ++nargv;
        for (sp = arglist.list ; sp ; sp = sp->next) {
                TRACE(("evalcommand arg: %s\n", sp->text));
                *nargv++ = sp->text;



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to