From f022af610d85e7b7cc4f63bf0491a738b5a6f082 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Fri, 20 Jun 2014 16:06:42 +0530 Subject: libglusterfs: Don't allow '-0' as input value for numbers Problem: io-stats tries to init log-buf-size as uint32. All gf_string2u*** functions which get the unsigned values from string don't want the string to contain '-'. So the GF_OPTION_INIT with '-0' as value fails init in io-stats, but by that time 'ret' is already reset to 0. Io-stats ends up returning 0 even when init failed. Because of this caller of init thinks initialization is successful when it is not. iostat_xlator->private is still NULL. Because of this when a fop tries to access members of io-stat-private structure, it crashes. Fix: I initially thought may be we should fix all gf_string2u*** functions to accept '-0'. But all these functions are used only for setting volume options. If we accept '-0', gluster volume info shows output as follows: diagnostics.brick-log-buf-size: -0 This seemed ugly, so I felt it is better to disallow '-0' as valid input for numbers. Also fixed return value in cases of failures in io-stats. Change-Id: I67ac92853b6d2be70516ad1d07505ffd9f058aa4 BUG: 1111557 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/8129 Reviewed-by: Krutika Dhananjay Tested-by: Gluster Build System Reviewed-by: Harshavardhana Tested-by: Harshavardhana Reviewed-by: Vijay Bellur --- tests/bugs/bug-1111557.t | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/bugs/bug-1111557.t (limited to 'tests') diff --git a/tests/bugs/bug-1111557.t b/tests/bugs/bug-1111557.t new file mode 100644 index 00000000000..656b6e6519b --- /dev/null +++ b/tests/bugs/bug-1111557.t @@ -0,0 +1,12 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 $H0:$B0/${V0}{0} +TEST $CLI volume set $V0 diagnostics.brick-log-buf-size 0 +TEST ! $CLI volume set $V0 diagnostics.brick-log-buf-size -0 +cleanup -- cgit