Re: [PATCH v3 1/9] ref-filter: add option to align atoms to the left

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH v3 1/9] ref-filter: add option to align atoms to the left

From: Matthieu Moy <hidden>
Date: 2016-06-15 23:05:51

Karthik Nayak [off-list ref] writes:
+			strtoul_ui(valp, 10, &ref->align_value);
+			if (ref->align_value < 1)
+				die(_("Value should be greater than zero"));
You're not checking the return value of strtoul_ui, which returns -1
before assigning align_value if the value can't be parsed. As a result,
you're testing an undefined value in the 'if' statement in this case.

You should test the return value and issue a distinct error message in
this case like

if (strtoul_ui(valp, 10, &ref->align_value))
	die(_("positive integer expected after ':' in align:%u\n",
	    ref_align_value));

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

Re: [PATCH v3 1/9] ref-filter: add option to align atoms to the left

From: Karthik Nayak <hidden>
Date: 2016-06-15 23:05:51

On Thu, Jul 23, 2015 at 12:14 AM, Matthieu Moy
[off-list ref] wrote:
Karthik Nayak [off-list ref] writes:
quoted
+                     strtoul_ui(valp, 10, &ref->align_value);
+                     if (ref->align_value < 1)
+                             die(_("Value should be greater than zero"));
You're not checking the return value of strtoul_ui, which returns -1
before assigning align_value if the value can't be parsed. As a result,
you're testing an undefined value in the 'if' statement in this case.

You should test the return value and issue a distinct error message in
this case like

if (strtoul_ui(valp, 10, &ref->align_value))
        die(_("positive integer expected after ':' in align:%u\n",
            ref_align_value));

--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Makes sense, thanks :)

-- 
Regards,
Karthik Nayak
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help