String comparison in hugetlb_setup_env is done in an inconsisten way. This could be a problem as using str[case]cmp instead of strncasecmp implies a level of trust in the data being handed in by the user. This patch alters all the calls to string comparison functions to be strncasecmp as they are elsewhere in the library.
Signed-off-by: Eric B Munson <emun...@mgebm.net> --- hugeutils.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hugeutils.c b/hugeutils.c index 70e3d22..156be65 100644 --- a/hugeutils.c +++ b/hugeutils.c @@ -336,11 +336,11 @@ void hugetlbfs_setup_env() __hugetlb_opts.heapbase = getenv("HUGETLB_MORECORE_HEAPBASE"); env = getenv("HUGETLB_FORCE_ELFMAP"); - if (env && (strcasecmp(env, "yes") == 0)) + if (env && (strncasecmp(env, "yes", 3) == 0)) __hugetlb_opts.force_elfmap = 1; env = getenv("HUGETLB_MINIMAL_COPY"); - if (__hugetlb_opts.min_copy && env && (strcasecmp(env, "no") == 0)) { + if (__hugetlb_opts.min_copy && env && (strncasecmp(env, "no", 2) == 0)) { INFO("HUGETLB_MINIMAL_COPY=%s, disabling filesz copy " "optimization\n", env); __hugetlb_opts.min_copy = false; @@ -366,17 +366,17 @@ void hugetlbfs_setup_env() * along with a patch to correct the behavior. */ env = getenv("HUGETLB_MORECORE_SHRINK"); - if (env && strcasecmp(env, "yes") == 0) + if (env && strncasecmp(env, "yes", 3) == 0) __hugetlb_opts.shrink_ok = true; /* Determine if shmget() calls should be overridden */ env = getenv("HUGETLB_SHM"); - if (env && !strcmp(env, "yes")) + if (env && !strncasecmp(env, "yes", 3)) __hugetlb_opts.shm_enabled = true; /* Determine if all reservations should be avoided */ env = getenv("HUGETLB_NO_RESERVE"); - if (env && !strcmp(env, "yes")) + if (env && !strncasecmp(env, "yes", 3)) __hugetlb_opts.no_reserve = true; } -- 1.7.4.1 ------------------------------------------------------------------------------ vRanger cuts backup time in half-while increasing security. With the market-leading solution for virtual backup and recovery, you get blazing-fast, flexible, and affordable data protection. Download your free trial now. http://p.sf.net/sfu/quest-d2dcopy1 _______________________________________________ Libhugetlbfs-devel mailing list Libhugetlbfs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel