Просмотр исходного кода

fix a buffer overflow in cmdname handling
Only abort if we fail to open an existing pidfile

Wichert Akkerman лет назад: 26
Родитель
Сommit
5cdb118820
3 измененных файлов с 18 добавлено и 6 удалено
  1. 6 0
      ChangeLog
  2. 4 0
      debian/changelog
  3. 8 6
      utils/start-stop-daemon.c

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+Thu Oct 19 00:59:40 CEST 2000 Wichert Akkerman <wakkerma@debian.org>
+
+  * utils/start-stop-daemon.c
+    + fix a buffer overflow in cmdname handling
+    + Only abort if we fail to open an existing pidfile
+
 Wed Oct 18 17:48:15 CEST 2000 Wichert Akkerman <wakkerma@debian.org>
 
   * scripts/dpkg-source.pl: patch from Colin Watson to not rename a

+ 4 - 0
debian/changelog

@@ -32,6 +32,10 @@ dpkg (1.7.0) unstable; urgency=low
   * dpkg-scanpackages now uses the most recent version if multiple versions
     of a package are found.
   * don't rename a file to itself in dpkg-source. Closes: Bug#75060
+  * Fix buffer overflow in cmdname handling in start-stop-daemon.
+    Closes: Bug#75103
+  * Don't abort if start-stop-daemon tries to read a non-existing pidfile.
+    Closes: Bug#75105
 
  -- Wichert Akkerman <wakkerma@debian.org>  UNRELEASED
 

+ 8 - 6
utils/start-stop-daemon.c

@@ -473,7 +473,9 @@ do_pidfile(const char *name)
 		if (fscanf(f, "%d", &pid) == 1)
 			check(pid);
 		fclose(f);
-	}
+	} else if (errno != ENOENT)
+		fatal("open pidfile %s: %s", name, strerror(errno));
+
 }
 
 /* WTA: this  needs to be an autoconf check for /proc/pid existance.
@@ -541,18 +543,18 @@ do_procinit(void)
 static int
 do_stop(void)
 {
-	char what[1024];
+	char what[2048];
 	struct pid_list *p;
 	int retval = 0;
 
 	if (cmdname)
-		strcpy(what, cmdname);
+		snprintf(what, sizeof(what), "%s", cmdname);
 	else if (execname)
-		strcpy(what, execname);
+		snprintf(what, sizeof(what), "%s", execname);
 	else if (pidfile)
-		sprintf(what, "process in pidfile `%s'", pidfile);
+		snprintf(what, sizeof(what), "process in pidfile `%s'", pidfile);
 	else if (userspec)
-		sprintf(what, "process(es) owned by `%s'", userspec);
+		snprintf(what, sizeof(what), "process(es) owned by `%s'", userspec);
 	else
 		fatal("internal error, please report");