Skip to contentSkip to conversation

parse_sun.c error

PATCH Brad Arrington 3 participants 3 messages Jul 23, 2006 – Jul 28, 2006 Kernel automounter

lore
Share & tools
lore
#0 lore raw

I have noticed that the following code in parse_sun.c has a duplicate memory allocation.

The error is present in both autofs-4.1.4 and autofs-5.0.1-rc1.

4.1.4

parse_sun.c

    650         what = alloca(loclen + 1);
    651         memcpy(what, loc, loclen);
    652         what[loclen] = '\0';
    653
    654         if (!strcmp(fstype, "autofs") && strchr(loc, ':') == NULL) {
    655                 char mtype[7];
    656                 int mtype_len;
    657
    658                 if (loc[0] == '/') {
    659                         mtype_len = 5;
    660                         if (loc[1] == '/')
    661                                 strcpy(mtype, "ldap:");
    662                         else
    663                                 strcpy(mtype, "file:");
    664                 } else {
    665                         mtype_len = 3;
    666                         strcpy(mtype, "yp:");
    667                 }
    668
    669                 what = alloca(loclen + mtype_len + 1);
    670                 memcpy(what, mtype, mtype_len);
    671                 memcpy(what + mtype_len, loc, loclen);
    672                 what[loclen + mtype_len] = '\0';
    673         } else {
    674                 what = alloca(loclen + 1);
    675                 memcpy(what, loc, loclen);
    676                 what[loclen] = '\0';
    677         }

5.0.1-rc1

    647         what = alloca(loclen + 1);
    648         memcpy(what, loc, loclen);
    649         what[loclen] = '\0';
    650 /*
    651         if (!strcmp(fstype, "autofs") && strchr(loc, ':') == NULL) {
    652                 char mtype[7];
    653                 int mtype_len;
    654
    655                 if (loc[0] == '/') {
    656                         mtype_len = 5;
    657                         if (loc[1] == '/')
    658                                 strcpy(mtype, "ldap:");
    659                         else
    660                                 strcpy(mtype, "file:");
    661                 } else {
    662                         mtype_len = 3;
    663                         strcpy(mtype, "yp:");
    664                 }
    665
    666                 what = alloca(loclen + mtype_len + 1);
    667                 memcpy(what, mtype, mtype_len);
    668                 memcpy(what + mtype_len, loc, loclen);
    669                 what[loclen + mtype_len] = '\0';
    670         } else {
    671 */
    672                 what = alloca(loclen + 1);
    673                 memcpy(what, loc, loclen);
    674                 what[loclen] = '\0';
    675 /*      } */
modules/parse_sun.c 2006-07-22 11:55:39.000000000 -0700 renamed from modules/parse_sun.c 2005-04-05 05:42:42.000000000 -0700 +0 -4
diff -ur autofs-4.1.4a/modules/parse_sun.c autofs-4.1.4b/modules/parse_sun.c
@@ -647,10 +647,6 @@
        mountpoint = alloca(namelen + 1);
        sprintf(mountpoint, "%.*s", namelen, name);
 
-       what = alloca(loclen + 1);
-       memcpy(what, loc, loclen);
-       what[loclen] = '\0';
-
        if (!strcmp(fstype, "autofs") && strchr(loc, ':') == NULL) {
                char mtype[7];
                int mtype_len;

_______________ cut __________________________

modules/parse_sun.c 2006-07-22 13:37:40.000000000 -0700 renamed from modules/parse_sun.c 2006-07-13 01:11:39.000000000 -0700 +0 -3
diff -ur autofs-5.0.1a/modules/parse_sun.c autofs-5.0.1b/modules/parse_sun.c
@@ -669,9 +669,6 @@
                what[loclen + mtype_len] = '\0';
        } else {
 */
-               what = alloca(loclen + 1);
-               memcpy(what, loc, loclen);
-               what[loclen] = '\0';
 /*     } */
 
        debug(ap->logopt,
#1 lore raw

==> Regarding [autofs] parse_sun.c error; Brad Arrington <[email protected]> adds:

Quoted 20 lines

diff -ur autofs-4.1.4a/modules/parse_sun.c autofs-4.1.4b/modules/parse_sun.c

modules/parse_sun.c 2006-07-22 11:55:39.000000000 -0700 renamed from modules/parse_sun.c 2005-04-05 05:42:42.000000000 -0700 +0 -4
@@ -647,10 +647,6 @@
        mountpoint = alloca(namelen + 1);
        sprintf(mountpoint, "%.*s", namelen, name);
 
-       what = alloca(loclen + 1);
-       memcpy(what, loc, loclen);
-       what[loclen] = '\0';
-
        if (!strcmp(fstype, "autofs") && strchr(loc, ':') == NULL) {
                char mtype[7];
                int mtype_len;

_______________ cut __________________________

diff -ur autofs-5.0.1a/modules/parse_sun.c autofs-5.0.1b/modules/parse_sun.c

modules/parse_sun.c 2006-07-22 13:37:40.000000000 -0700 line 674

Quoted 9 lines
modules/parse_sun.c 2006-07-22 13:37:40.000000000 -0700 renamed from modules/parse_sun.c 2006-07-13 01:11:39.000000000 -0700 +0 -3
@@ -669,9 +669,6 @@
                what[loclen + mtype_len] = '\0';
        } else {
 */
-               what = alloca(loclen + 1);
-               memcpy(what, loc, loclen);
-               what[loclen] = '\0';
 /*     } */
 
        debug(ap->logopt,

Looks sane to me.

-Jeff

maintainer
#2 lore raw
In reply to Brad Arrington

On Sun, 23 Jul 2006, Brad Arrington wrote:

Thanks Brad,

Quoted 2 lines

5.0.1-rc1

Apply the patches on kernel.org and check again. I think you'll find this is completely different now.

Quoted 22 lines
    647         what = alloca(loclen + 1);
    648         memcpy(what, loc, loclen);
    649         what[loclen] = '\0';
    650 /*
    651         if (!strcmp(fstype, "autofs") && strchr(loc, ':') == NULL) {
    652                 char mtype[7];
    653                 int mtype_len;
    654
    655                 if (loc[0] == '/') {
    656                         mtype_len = 5;
    657                         if (loc[1] == '/')
    658                                 strcpy(mtype, "ldap:");
    659                         else
    660                                 strcpy(mtype, "file:");
    661                 } else {
    662                         mtype_len = 3;
    663                         strcpy(mtype, "yp:");
    664                 }
    665
    666                 what = alloca(loclen + mtype_len + 1);
    667                 memcpy(what, mtype, mtype_len);
Quoted 9 lines
    668                 memcpy(what + mtype_len, loc, loclen);
    669                 what[loclen + mtype_len] = '\0';
    670         } else {
    671 */
    672                 what = alloca(loclen + 1);
    673                 memcpy(what, loc, loclen);
    674                 what[loclen] = '\0';
    675 /*      } */

Ian