[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#676331: libapt-pkg4.12: segfault in CommandLine::Parse if Args has null LongOpt



Package: libapt-pkg4.12
Version: 0.9.5.1
Severity: minor

apt-pkg/contrib/cmndline.h

>From the definition of CommandLine::Args::end() either ShortOpt or
LongOpt may be NULL.  However, any Args with LongOpt NULL will cause a
segfault in CommandLine::Parse at this point:

      // Match up to a = against the list
      Args *A;
      const char *OptEnd = strchrnul(Opt, '=');
      for (A = ArgList; A->end() == false &&
	   stringcasecmp(Opt,OptEnd,A->LongOpt) != 0; A++);

Checking for A->LongOpt == 0 before stringcasecmp, as in the attached
patch, is sufficient to avoid this.

Attachment: cmndline-null-longopt.patch
Description: Binary data

Attachment: test.cc
Description: Binary data


Reply to: