Sorry for the delay responding.

A week or two ago I shared a couple of patches. One of these had an
incomprehensible commit message (so full of typos it was hard to read).

I have re-written the commit message this time. I hope it makes sense now!


Daniel.
From: Daniel Thompson <[email protected]>
Date: Fri, 4 Oct 2013 08:34:05 +0100
Subject: [PATCH] agilent-dmm: Fix SEGV during incomplete reply from meter.

If buf contains exactly the string "Agilent Technologies" (for example if
there are bugs in the timeout logic or serial driver causing the reply from
the meter to be abridged) then this code will SEGV. This is because tokens[1]
is NULL but only tokens[2] and tokens[3] (both of which are undefined) are
NULL checked.

Can be trivially corrected by NULL checking tokens[1] as well.

Signed-off-by: Daniel Thompson <[email protected]>

diff --git a/hardware/agilent-dmm/api.c b/hardware/agilent-dmm/api.c
index 34fa92a..4a1274d 100644
--- a/hardware/agilent-dmm/api.c
+++ b/hardware/agilent-dmm/api.c
@@ -129,7 +129,7 @@ static GSList *scan(GSList *options)
 
 	tokens = g_strsplit(buf, ",", 4);
 	if (!strcmp("Agilent Technologies", tokens[0])
-			&& tokens[2] && tokens[3]) {
+			&& tokens[1] && tokens[2] && tokens[3]) {
 		for (i = 0; supported_agdmm[i].model; i++) {
 			if (strcmp(supported_agdmm[i].modelname, tokens[1]))
 				continue;
-- 
1.8.3.1

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to