[PATCH 07/10] parser: Don't pass a message-id longer than 255 chars to the db

Daniel Axtens dja at axtens.net
Thu Jun 29 00:03:28 AEST 2017


It turns out we need to extend this to email and name fields as well;
that just popped up in the fuzzer. I'll send a followup.

Regards,
Daniel

Andrew Donnellan <andrew.donnellan at au1.ibm.com> writes:

> On 28/06/17 17:48, Daniel Axtens wrote:
>> The db limit is 255: we need to make sure we don't pass anything
>> longer in or it will throw an exception.
>>
>> Signed-off-by: Daniel Axtens <dja at axtens.net>
>
> Reviewed-by: Andrew Donnellan <andrew.donnellan at au1.ibm.com>
>
>> ---
>>  patchwork/parser.py | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/patchwork/parser.py b/patchwork/parser.py
>> index 80450c2e4860..46e6ca161574 100644
>> --- a/patchwork/parser.py
>> +++ b/patchwork/parser.py
>> @@ -225,7 +225,7 @@ def _find_series_by_references(project, mail):
>>      for ref in refs:
>>          try:
>>              return SeriesReference.objects.get(
>> -                msgid=ref, series__project=project).series
>> +                msgid=ref[:255], series__project=project).series
>>          except SeriesReference.DoesNotExist:
>>              continue
>>
>> @@ -557,6 +557,7 @@ def find_comment_content(mail):
>>
>>  def find_submission_for_comment(project, refs):
>>      for ref in refs:
>> +        ref = ref[:255]
>>          # first, check for a direct reply
>>          try:
>>              submission = Submission.objects.get(project=project, msgid=ref)
>> @@ -934,7 +935,7 @@ def parse_mail(mail, list_id=None):
>>      msgid = clean_header(mail.get('Message-Id'))
>>      if not msgid:
>>          raise ValueError("Broken 'Message-Id' header")
>> -    msgid = msgid.strip()
>> +    msgid = msgid.strip()[:255]
>>
>>      author = find_author(mail)
>>      subject = mail.get('Subject')
>> @@ -993,6 +994,7 @@ def parse_mail(mail, list_id=None):
>>              # be possible to identify the relationship between patches
>>              # as the earlier patch does not reference the later one.
>>              for ref in refs + [msgid]:
>> +                ref = ref[:255]
>>                  # we don't want duplicates
>>                  try:
>>                      # we could have a ref to a previous series. (For
>>
>
> -- 
> Andrew Donnellan              OzLabs, ADL Canberra
> andrew.donnellan at au1.ibm.com  IBM Australia Limited


More information about the Patchwork mailing list