Date: Sat, 25 Aug 2001 12:55:22 -0700 (PDT) From: Michael Joyner <wolfieee@wolf.dyns.cx> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/30083: mtoolsfm has serious bug when started in paths > 49 char's. Message-ID: <200108251955.f7PJtMl22578@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 30083 >Category: ports >Synopsis: mtoolsfm has serious bug when started in paths > 49 char's. >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Aug 25 13:00:01 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Michael Joyner >Release: 4.3-20010721-STABLE >Organization: Edward Waters College >Environment: FreeBSD host100.internal 4.3-20010721-STABLE FreeBSD 4.3-20010721-STABLE #1: Sun Aug 5 16:39:18 EDT 2001 root@:/usr/src/sys/compile/workstation i386 >Description: The mtoolsfm port has a routine that is supposed to dynamically resize the buffer for getcwd. This code is seriously flawed and will fail if mtools starts up in a dir that is greater than 49 chars. >How-To-Repeat: Start up mtools in a dir that is greater than 49 bytes in length. >Fix: --- mtoolsfm.c.orig Sat Aug 25 15:30:09 2001 +++ mtoolsfm.c Sat Aug 25 15:36:21 2001 @@ -463,15 +463,21 @@ char *path = NULL; char *position; char *nextposition; + unsigned int path_length=50; + unsigned int path_add=50; + if (debug) { printf ("In gethdpath()\n"); printf (" whichside: %p\n", whichside); } clearpath (whichside); errno = 0; - path = malloc (50 * sizeof (char)); - while ((!getcwd (path, 49)) && (errno == ERANGE)) - path = g_realloc (path, (strlen (path) + 50) * sizeof (char)); + path = malloc (path_length * sizeof (char)); + while ((!getcwd (path, path_length - 2)) && (errno == ERANGE)) + { + if (debug) printf(" getcwd buffer resize: errno=%d, path_length=%d, path=%s\n",errno,path_length,path); + path = g_realloc (path, (path_length+=path_add) * sizeof (char)); + } strcat (path, "/"); if (debug) printf (" path: %s\n", path); >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200108251955.f7PJtMl22578>