lsb

dead code, possibly unintentional, in elfchk

Bug #1327654 reported by Jeff Johnson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lsb
Fix Committed
Medium
Unassigned
Mandriva
Fix Released
Medium

Bug Description

As reported by Coverity scan, in elfchk/proghdr.c:checkPT_NOTE_combined(),
which starts at line 328:

333 int first_note = 1;

inside the for loop beginning at line 353:

359 /* check only the first note section for alignment with the segment
    */
360 if (!first_note) continue;
361 else first_note = 0;

If we *are* the first note found, we set the marker to 0 (meaning we've already
seen a note, so any subsequent note sections will be skipped). But then after
another check we see:

372 if (first_note && file->saddr[i].sh_offset != hdr->p_offset) {
373 snprintf(tmp_string, TMP_STRING_SIZE,
374 "NOTE section offset does not match Segment offset: %#x
v s. %#x",
375 (unsigned int) file->saddr[i].sh_offset,
376 (unsigned int) hdr->p_offset);
377 tetj_testcase_info(journal, tetj_activity_count,
378 tetj_tp_count, 0, 0, 0, tmp_string);
379 fprintf(stderr, "%s\n", tmp_string);
380 fail = 1;
381 }

Since first_note is guaranteed to be zero after lines 360/361, this "if" test
always fails. Presumably this was not what was intended... but only guessing,
so filing an issue so someone else can take a look too. At this point it
*looks* like we're trying to make sure we're in first_note code, but we already
know we are after line 360, and since we've already set the marker, we should
either drop the first part of the test, or move line 361 to the end of the
block (current line 394), or both.

Opinions?

Tags: vip
Changed in mandriva:
importance: Unknown → Medium
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.