subprocess bencoded stream is fragile re multiline strings

Bug #570564 reported by Alexander Belchenko
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
QBzr
Fix Released
Critical
Alexander Belchenko

Bug Description

Steps to reproduce:

Run qpush, push to lp without ssh-agent running (or without ssh key loaded into agent, e.g. pageant). Push will fail with error about publickey and qpush produce following traceback:

bzr: ERROR: exceptions.ValueError: stream underflow

Traceback (most recent call last):
  File "C:\work\Bazaar\plugins\qbzr\lib\subprocess.py", line 652, in readStdout
  File "_bencode_pyx.pyx", line 225, in bzrlib._bencode_pyx.bdecode
  File "_bencode_pyx.pyx", line 90, in bzrlib._bencode_pyx.Decoder.decode
  File "_bencode_pyx.pyx", line 112, in bzrlib._bencode_pyx.Decoder._decode_object
  File "_bencode_pyx.pyx", line 193, in bzrlib._bencode_pyx.Decoder._decode_list
  File "_bencode_pyx.pyx", line 118, in bzrlib._bencode_pyx.Decoder._decode_object
  File "_bencode_pyx.pyx", line 217, in bzrlib._bencode_pyx.Decoder._decode_dict
  File "_bencode_pyx.pyx", line 109, in bzrlib._bencode_pyx.Decoder._decode_object
  File "_bencode_pyx.pyx", line 171, in bzrlib._bencode_pyx.Decoder._decode_string
ValueError: stream underflow

bzr 2.1.1 on python 2.5.4 (win32)
arguments: ['C:\\Program Files\\Bazaar\\bzr.EXE', 'qpush']
encoding: 'cp1251', fsenc: 'mbcs', lang: None
plugins:
  acad C:\work\Bazaar\plugins\acad [0.8.0]
  bzrtools C:\Program Files\Bazaar\plugins\bzrtools [2.1.0]
  colo C:\work\Bazaar\plugins\colo [0.2.0dev]
  explorer C:\work\Bazaar\plugins\explorer [1.0.0]
  format1 C:\work\Bazaar\plugins\format1 [unknown]
  launchpad C:\Program Files\Bazaar\plugins\launchpad [2.1.1]
  qbzr C:\work\Bazaar\plugins\qbzr [0.19.0dev1]
  rebase C:\Program Files\Bazaar\plugins\rebase [0.5.5]
  scmproj C:\work\Bazaar\plugins\scmproj [0.6.0]
  svn C:\Program Files\Bazaar\plugins\svn [1.0.2]
  x_bit C:\work\Bazaar\plugins\x_bit [1.0.0]

The problem here is bzr produce multiline error message:

bzr: ERROR: Connection error: Unable to authenticate to SSH host as
  <email address hidden>
supported auth types: ['publickey']

But we send this as one string and put into bencode container (to allow status window process it differently).

Our bencode streams all affected by this problem. I've fixed some edge cases in the past, but we have to redesign this streams entirely: either encode \n somehow, so pipe won't break it into separate lines, or split them into separate lines and send them as multiple bencoded lines. I think the former is preferable way because it could be a password prompt or something similar (look for bzr-git password prompt issue bug #dont-remeber-number-offhand).

Tags: subprocess

Related branches

Changed in qbzr:
milestone: none → 0.19b2
Changed in qbzr:
importance: High → Critical
Changed in qbzr:
assignee: nobody → Alexander Belchenko (bialix)
Revision history for this message
Alexander Belchenko (bialix) wrote :

To debug:

bzr qsubprocess pull >stdout 2>stderr

stdout:

Using saved parent location: bzr+ssh://bazaar.launchpad.net/~qbzr-dev/qbzr/trunk2a/
qbzr:ERROR:l15:ConnectionErrord3:msg103:Unable to authenticate to SSH host as
  <email address hidden>
supported auth types: ['publickey']10:orig_error0:ee

Changed in qbzr:
status: Confirmed → 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.