Bug 144761 - FTPD bug remote crash
Summary: FTPD bug remote crash
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 8.0-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Xin LI
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-15 12:40 UTC by David BERARD
Modified: 2010-04-01 01:40 UTC (History)
1 user (show)

See Also:


Attachments
ftpd_popen.patch (461 bytes, patch)
2010-03-15 12:40 UTC, David BERARD
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David BERARD 2010-03-15 12:40:07 UTC
FTPD child process can die with signal 11, bug found by Kingcope
	kernel: pid 46033 (ftpd), uid 1001: exited on signal 11
References :
	http://seclists.org/fulldisclosure/2010/Mar/117
	http://seclists.org/fulldisclosure/2010/Mar/138
	http://seclists.org/fulldisclosure/2010/Mar/139

Fix: See the attached patch, should fix issue
How-To-Repeat: 	ftp localhost
	[....login....]
	ftp> mkdir WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
	ftp> ls {W*/../W*/../W*/../W*/../W*/../W*/../W*/}
	[....Server close connection....]
Comment 1 Gavin Atkinson freebsd_committer freebsd_triage 2010-03-20 14:48:34 UTC
Responsible Changed
From-To: freebsd-standards->freebsd-bugs

Not a PR for standards@
Comment 2 Rebecca Cran freebsd_committer 2010-03-20 22:51:45 UTC
This has been fixed in the NetBSD repository - see http://www.netbsd.org/cgi-
bin/query-pr-single.pl?number=43023

-- 
Bruce Cran
Comment 3 Xin LI freebsd_committer 2010-03-25 22:41:11 UTC
State Changed
From-To: open->patched

Patch from OpenBSD applied, thanks for bringing this to our 
attention! 


Comment 4 Xin LI freebsd_committer 2010-03-25 22:41:11 UTC
Responsible Changed
From-To: freebsd-bugs->delphij

Take since I have patched this issue.
Comment 5 dfilter service freebsd_committer 2010-03-25 22:41:11 UTC
Author: delphij
Date: Thu Mar 25 22:41:01 2010
New Revision: 205656
URL: http://svn.freebsd.org/changeset/base/205656

Log:
  Check that gl_pathc is bigger than zero before derefencing gl_pathv.
  When gl_pathc == 0, the content of gl_pathv is undefined.
  
  PR:		bin/144761
  Submitted by:	David BERARD <contact davidberard fr>
  Obtained from:	OpenBSD
  MFC after:	1 week

Modified:
  head/libexec/ftpd/popen.c

Modified: head/libexec/ftpd/popen.c
==============================================================================
--- head/libexec/ftpd/popen.c	Thu Mar 25 20:07:30 2010	(r205655)
+++ head/libexec/ftpd/popen.c	Thu Mar 25 22:41:01 2010	(r205656)
@@ -110,10 +110,11 @@ ftpd_popen(char *program, char *type)
 		flags |= GLOB_LIMIT;
 		if (glob(argv[argc], flags, NULL, &gl))
 			gargv[gargc++] = strdup(argv[argc]);
-		else
+		else if (gl.gl_pathc > 0) {
 			for (pop = gl.gl_pathv; *pop && gargc < (MAXGLOBARGS-1);
 			     pop++)
 				gargv[gargc++] = strdup(*pop);
+		}
 		globfree(&gl);
 	}
 	gargv[gargc] = NULL;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 6 dfilter service freebsd_committer 2010-04-01 01:38:48 UTC
Author: delphij
Date: Thu Apr  1 00:38:38 2010
New Revision: 206025
URL: http://svn.freebsd.org/changeset/base/206025

Log:
  MFC r205656:
  
  Check that gl_pathc is bigger than zero before derefencing gl_pathv.
  When gl_pathc == 0, the content of gl_pathv is undefined.
  
  PR:		bin/144761
  Submitted by:	David BERARD <contact davidberard fr>
  Obtained from:	OpenBSD

Modified:
  stable/8/libexec/ftpd/popen.c
Directory Properties:
  stable/8/libexec/ftpd/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/6/libexec/ftpd/popen.c
  stable/7/libexec/ftpd/popen.c
Directory Properties:
  stable/6/libexec/ftpd/   (props changed)
  stable/7/libexec/ftpd/   (props changed)

Modified: stable/8/libexec/ftpd/popen.c
==============================================================================
--- stable/8/libexec/ftpd/popen.c	Thu Apr  1 00:36:40 2010	(r206024)
+++ stable/8/libexec/ftpd/popen.c	Thu Apr  1 00:38:38 2010	(r206025)
@@ -110,10 +110,11 @@ ftpd_popen(char *program, char *type)
 		flags |= GLOB_LIMIT;
 		if (glob(argv[argc], flags, NULL, &gl))
 			gargv[gargc++] = strdup(argv[argc]);
-		else
+		else if (gl.gl_pathc > 0) {
 			for (pop = gl.gl_pathv; *pop && gargc < (MAXGLOBARGS-1);
 			     pop++)
 				gargv[gargc++] = strdup(*pop);
+		}
 		globfree(&gl);
 	}
 	gargv[gargc] = NULL;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 7 Xin LI freebsd_committer 2010-04-01 01:38:53 UTC
State Changed
From-To: patched->closed

Fixed in {6,7.8}-STABLE.
Comment 8 dfilter service freebsd_committer 2010-04-01 01:39:09 UTC
Author: delphij
Date: Thu Apr  1 00:38:38 2010
New Revision: 206025
URL: http://svn.freebsd.org/changeset/base/206025

Log:
  MFC r205656:
  
  Check that gl_pathc is bigger than zero before derefencing gl_pathv.
  When gl_pathc == 0, the content of gl_pathv is undefined.
  
  PR:		bin/144761
  Submitted by:	David BERARD <contact davidberard fr>
  Obtained from:	OpenBSD

Modified:
  stable/7/libexec/ftpd/popen.c
Directory Properties:
  stable/7/libexec/ftpd/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/6/libexec/ftpd/popen.c
  stable/8/libexec/ftpd/popen.c
Directory Properties:
  stable/6/libexec/ftpd/   (props changed)
  stable/8/libexec/ftpd/   (props changed)

Modified: stable/7/libexec/ftpd/popen.c
==============================================================================
--- stable/7/libexec/ftpd/popen.c	Thu Apr  1 00:36:40 2010	(r206024)
+++ stable/7/libexec/ftpd/popen.c	Thu Apr  1 00:38:38 2010	(r206025)
@@ -110,10 +110,11 @@ ftpd_popen(char *program, char *type)
 		flags |= GLOB_LIMIT;
 		if (glob(argv[argc], flags, NULL, &gl))
 			gargv[gargc++] = strdup(argv[argc]);
-		else
+		else if (gl.gl_pathc > 0) {
 			for (pop = gl.gl_pathv; *pop && gargc < (MAXGLOBARGS-1);
 			     pop++)
 				gargv[gargc++] = strdup(*pop);
+		}
 		globfree(&gl);
 	}
 	gargv[gargc] = NULL;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"