Package: make
Version: 3.81-8.2
Severity: normal
Tags: upstream patch

Dear Maintainer,
*** Please consider answering these questions, where appropriate ***

   * What led up to the situation?

Running make against commit hash 1a4b795432 in
https://github.com/pastcompute/hdp15
after the antares/ subfolder had updated

The offending makefile is actually in https://github.com/pastcompute/antares

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

The following line, the last line in the Makefile causes the crash

..DEFAULT_GOAL := $(subst ",, $(CONFIG_MAKE_DEFTARGET))

   * What was the outcome of this action?

I rebuilt make-3.81 from debian apt-sources and got a stack trace on line 2168
of main.c

ns (below) is a null pointer,

                    ns = multi_glob (
                      parse_file_seq (&p, '\0', sizeof (struct nameseq), 1),
                      sizeof (struct nameseq));

Line 2168:      if (ns->next != 0)
                        fatal (NILF, _(".DEFAULT_GOAL contains more than one
target"));

                      default_goal_file = enter_file (ns->name);

                      ns->name = 0; /* It was reused by enter_file(). */
                      free_ns_chain (ns);


   * What outcome did you expect instead?

Not a crash...

Interestingly the same error doesn't happen for me against
https://github.com/pastcompute/esp8266-frankenstein which uses exactly the same
code in antares/  So I presume it is something to do with CONFIG_MAKE_DEFTARGET
being empty and some edge case in parsing

I could fix it by wrapping the offending code with `if (ns) { ... }` and
aborting if NULL.
 Patch is attached.


*** End of the template - remove these lines ***



-- System Information:
Debian Release: 7.2
  APT prefers testing
  APT policy: (990, 'testing'), (700, 'stable'), (500, 'stable-updates'), (500, 
'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.2.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages make depends on:
ii  libc6  2.13-38

make recommends no packages.

Versions of packages make suggests:
pn  make-doc  <none>

-- no debconf information
>From f0ec1eb40563f52ec3f02bb0a3e158d48bf6acbc Mon Sep 17 00:00:00 2001
From: Andrew McDonnell <b...@andrewmcdonnell.net>
Date: Thu, 19 Mar 2015 20:30:35 +1030
Subject: [PATCH] Fix crash when default goal resolves to empty because of an
 empty variable

---
 main.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/main.c b/main.c
index 483babf..c4fae4f 100644
--- a/main.c
+++ b/main.c
@@ -2165,13 +2165,15 @@ main (int argc, char **argv, char **envp)
                       sizeof (struct nameseq));
 
                     /* .DEFAULT_GOAL should contain one target. */
-                    if (ns->next != 0)
-                      fatal (NILF, _(".DEFAULT_GOAL contains more than one target"));
+                    if (ns != 0) {
+                      if (ns->next != 0)
+                        fatal (NILF, _(".DEFAULT_GOAL contains more than one target"));
 
-                    default_goal_file = enter_file (ns->name);
+                      default_goal_file = enter_file (ns->name);
 
-                    ns->name = 0; /* It was reused by enter_file(). */
-                    free_ns_chain (ns);
+                      ns->name = 0; /* It was reused by enter_file(). */
+                      free_ns_chain (ns);
+                    } else { fatal (NILF, _(".DEFAULT_GOAL is invalid")); }
                   }
               }
 
-- 
1.9.1

Reply via email to