Project

General

Profile

Actions

Bug #6697

closed

strncmp(3) must not be used on binary data

Added by Alan Somers over 10 years ago. Updated over 9 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
-
Target version:
-
% Done:

80%

Source:
other
Tags:
Backport:
Regression:
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):

Description

strncmp(3) is intended to compare C strings, so it quits comparing after encountering a null character. The Linux man page is ambiguous on this point, but section 4.11.4.4 of the ANSI C standard is clear. Ceph mostly uses strncmp correctly, but uses it on binary data in these places:

msg/msg_types.h:30, 33
test_librbd.cc:861, 847, 861
TestErasureCodeJerasure.cc:70, 71, 85, 86, 104, 105 (I'm not sure whether these are guaranteed to be C Strings or not)

http://flash-gordon.me.uk/ansi.c.txt

Actions #1

Updated by Loïc Dachary over 9 years ago

  • Status changed from New to 12
  • Assignee set to Loïc Dachary
Actions #2

Updated by Loïc Dachary over 9 years ago

  • Status changed from 12 to Fix Under Review
  • % Done changed from 0 to 80
Actions #3

Updated by Loïc Dachary over 9 years ago

  • Status changed from Fix Under Review to Resolved
Actions

Also available in: Atom PDF