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 <daniel@redfelineninja.org.uk>
This commit is contained in:
Daniel Thompson 2013-10-04 08:34:05 +01:00 committed by Bert Vermeulen
부모 5715e84fe3
커밋 fbf07e0209
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제

파일 보기

@ -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;