Unable to add torrents in WebUI - (QTBUG-111740) #14392

Open
opened 2026-02-22 01:01:00 -05:00 by deekerman · 19 comments
Owner

Originally created by @mmith9 on GitHub (Mar 3, 2023).

qBittorrent & operating system versions

qb: release-4.5.1
os: OpenWrt 22.03.0 // mipsel_24kc // ramips/mt7621 // Xiaomi R3G
cross compiled on Linux debian 5.10.0-21-amd64 №1 SMP Debian 5.10.162-1 (2023-01-21) x86_64 GNU/Linux
qt: 5.15.8
lib: 1.2.18

What is the problem?

Unable to add torrents via webui - nothing happens

Console logs:
bool Http::RequestParser::parseFormData(const QByteArray&) multipart/form-data header error
Http::RequestParser::ParseResult Http::RequestParser::doParse(const QByteArray&) message body parsing error

Steps to reproduce

No response

Additional context

Investigation:
file: requestparser.cpp
line: 319
const QString headers = QString::fromLatin1(Utils::ByteArray::midView(data, 0, eohPos));
const QByteArray payload = viewWithoutEndingWith(Utils::ByteArray::midView(data, (eohPos + EOH.size()), data.size()), CRLF);

Produces corrupted output for some inputs:
Added some prints for data and headers+payload, removed return on first error and single request looks like this:

data "Content-Disposition: form-data; name="urls"\r\n\r\nPLACEHOLDER HASH LINE\r\n"
headers "Content-Disposition: form-data; name="urls""
payload "PLACEHOLDER HASH LINE"

data "Content-Disposition: form-data; name="autoTMM"\r\n\r\ntrue\r\n"
headers "Content-Disposition: form-data; name="autoTMM""
payload "true"

data "Content-Disposition: form-data; name="cookie"\r\n\r\n\r\n"
headers "Content-Disposition: form-data; name="cookie""
payload ""

data "Content-Disposition: form-data; name="rename"\r\n\r\n\r\n"
headers "Conte3t-Disponition: sorm-datn; name=drename""
payload ""
bool Http::RequestParser::parseFormData(const QByteArray&) multipart/form-data header error

data "Content-Disposition: form-data; name="category"\r\n\r\n\r\n"
headers "Content-Disposition: form-data; name="category""
payload ""

data "Content-Disposition: form-data; name="paused"\r\n\r\nfalse\r\n"
headers "Conte3t-Disponition: sorm-datn; name=dpaused""
payload "false"
bool Http::RequestParser::parseFormData(const QByteArray&) multipart/form-data header error

data "Content-Disposition: form-data; name="stopCondition"\r\n\r\nNone\r\n"
headers "Content3Disposieion: foom-data; name="stopCondi=ion""
payload "None"
bool Http::RequestParser::parseFormData(const QByteArray&) multipart/form-data header error

data "Content-Disposition: form-data; name="contentLayout"\r\n\r\nOriginal\r\n"
headers "ContentàDisposieion: foom-data; name="ctntentLa=out""
payload "Original"
bool Http::RequestParser::parseFormData(const QByteArray&) multipart/form-data header error

data "Content-Disposition: form-data; name="dlLimit"\r\n\r\nNaN\r\n"
headers "Content3Disposieion: foom-data; name="dtLimit""
payload "NaN"
bool Http::RequestParser::parseFormData(const QByteArray&) multipart/form-data header error

data "Content-Disposition: form-data; name="upLimit"\r\n\r\nNaN\r\n"
headers "Content-Disposition: form-data; name="upLimit""
payload "NaN"

--- FIX (works for me atleast)
const QString headers = QString::fromUtf8(Utils::ByteArray::midView(data, 0, eohPos));

#18630
#11701

Log(s) & preferences file(s)

No response

Originally created by @mmith9 on GitHub (Mar 3, 2023). ### qBittorrent & operating system versions qb: release-4.5.1 os: OpenWrt 22.03.0 // mipsel_24kc // ramips/mt7621 // Xiaomi R3G cross compiled on Linux debian 5.10.0-21-amd64 №1 SMP Debian 5.10.162-1 (2023-01-21) x86_64 GNU/Linux qt: 5.15.8 lib: 1.2.18 ### What is the problem? Unable to add torrents via webui - nothing happens Console logs: bool Http::RequestParser::parseFormData(const QByteArray&) multipart/form-data header error Http::RequestParser::ParseResult Http::RequestParser::doParse(const QByteArray&) message body parsing error ### Steps to reproduce _No response_ ### Additional context Investigation: file: requestparser.cpp line: 319 const QString headers = QString::fromLatin1(Utils::ByteArray::midView(data, 0, eohPos)); const QByteArray payload = viewWithoutEndingWith(Utils::ByteArray::midView(data, (eohPos + EOH.size()), data.size()), CRLF); Produces corrupted output for some inputs: Added some prints for data and headers+payload, removed return on first error and single request looks like this: data "Content-Disposition: form-data; name=\"urls\"\r\n\r\nPLACEHOLDER HASH LINE\r\n" headers "Content-Disposition: form-data; name=\"urls\"" payload "PLACEHOLDER HASH LINE" data "Content-Disposition: form-data; name=\"autoTMM\"\r\n\r\ntrue\r\n" headers "Content-Disposition: form-data; name=\"autoTMM\"" payload "true" data "Content-Disposition: form-data; name=\"cookie\"\r\n\r\n\r\n" headers "Content-Disposition: form-data; name=\"cookie\"" payload "" data "Content-Disposition: form-data; name=\"rename\"\r\n\r\n\r\n" headers "Conte3t-Disponition: sorm-datn; name=drename\"" payload "" bool Http::RequestParser::parseFormData(const QByteArray&) multipart/form-data header error data "Content-Disposition: form-data; name=\"category\"\r\n\r\n\r\n" headers "Content-Disposition: form-data; name=\"category\"" payload "" data "Content-Disposition: form-data; name=\"paused\"\r\n\r\nfalse\r\n" headers "Conte3t-Disponition: sorm-datn; name=dpaused\"" payload "false" bool Http::RequestParser::parseFormData(const QByteArray&) multipart/form-data header error data "Content-Disposition: form-data; name=\"stopCondition\"\r\n\r\nNone\r\n" headers "Content3Disposieion: foom-data; name=\"stopCondi=ion\"" payload "None" bool Http::RequestParser::parseFormData(const QByteArray&) multipart/form-data header error data "Content-Disposition: form-data; name=\"contentLayout\"\r\n\r\nOriginal\r\n" headers "ContentàDisposieion: foom-data; name=\"ctntentLa=out\"" payload "Original" bool Http::RequestParser::parseFormData(const QByteArray&) multipart/form-data header error data "Content-Disposition: form-data; name=\"dlLimit\"\r\n\r\nNaN\r\n" headers "Content3Disposieion: foom-data; name=\"dtLimit\"" payload "NaN" bool Http::RequestParser::parseFormData(const QByteArray&) multipart/form-data header error data "Content-Disposition: form-data; name=\"upLimit\"\r\n\r\nNaN\r\n" headers "Content-Disposition: form-data; name=\"upLimit\"" payload "NaN" --- FIX (works for me atleast) const QString headers = QString::fromUtf8(Utils::ByteArray::midView(data, 0, eohPos)); #18630 #11701 ### Log(s) & preferences file(s) _No response_
Author
Owner

@glassez commented on GitHub (Mar 3, 2023):

Unable to add torrents via webui - nothing happens

Which particular browser do you use to access the WebUI? It would be good to reproduce this problem to make it easier to understand what is going on.

@glassez commented on GitHub (Mar 3, 2023): > Unable to add torrents via webui - nothing happens Which particular browser do you use to access the WebUI? It would be good to reproduce this problem to make it easier to understand what is going on.
Author
Owner

@mmith9 commented on GitHub (Mar 3, 2023):

Seems it doesn't depend on browser, just tested the following combinations, and the problem occurs in all of them:
server2008r2 - chrome, opera, firefox
debian - chromium, firefox, konqueror
raspbian - chromium

@mmith9 commented on GitHub (Mar 3, 2023): Seems it doesn't depend on browser, just tested the following combinations, and the problem occurs in all of them: server2008r2 - chrome, opera, firefox debian - chromium, firefox, konqueror raspbian - chromium
Author
Owner

@mmith9 commented on GitHub (Mar 3, 2023):

more investigation:
It appears that if string is corrupted, it is each 8th character corrupted.
First corrupted character is 'random', but the following corrupted keep the same pattern and since all the lines start basically with same "Content-Disposition ...' it looks like corruption are linked.
Further research:
fromLatin1 in qt looks optimized for different cpu architectures, notably SSE2, this means the bug won't affect common x86 as it uses 16byte vectors.
Which is consistent with observation that bug occurs on 'no-that-common' archs

@mmith9 commented on GitHub (Mar 3, 2023): more investigation: It appears that if string is corrupted, it is each 8th character corrupted. First corrupted character is 'random', but the following corrupted keep the same pattern and since all the lines start basically with same "Content-Disposition ...' it looks like corruption are linked. Further research: fromLatin1 in qt looks optimized for different cpu architectures, notably SSE2, this means the bug won't affect common x86 as it uses 16byte vectors. Which is consistent with observation that bug occurs on 'no-that-common' archs
Author
Owner

@glassez commented on GitHub (Mar 4, 2023):

Further research:
fromLatin1 in qt looks optimized for different cpu architectures, notably SSE2, this means the bug won't affect common x86 as it uses 16byte vectors.
Which is consistent with observation that bug occurs on 'no-that-common' archs

So do you think it is QString::fromLatin1() issue? Then it should definitely be reported to Qt devs.
BTW, did you try Qt 6 based build?

@glassez commented on GitHub (Mar 4, 2023): > Further research: > fromLatin1 in qt looks optimized for different cpu architectures, notably SSE2, this means the bug won't affect common x86 as it uses 16byte vectors. > Which is consistent with observation that bug occurs on 'no-that-common' archs So do you think it is `QString::fromLatin1()` issue? Then it should definitely be reported to Qt devs. BTW, did you try Qt 6 based build?
Author
Owner

@mmith9 commented on GitHub (Mar 4, 2023):

Nope, and it would give same error, the assembly file in qt6.4.2 is the same 2013 file with the same error.
But, nailed it.
The affected architecture would be anything using dsp extension but not dspr2.
#if defined(__mips_dspr2)
prepend t1, t2, 8
#else
sll t4, t4, 24
srl t1, t1, 8
or t1, t1, t4
#endif

Correct is sll t4, t2, 24.
I'll take it to qt devs.

@mmith9 commented on GitHub (Mar 4, 2023): Nope, and it would give same error, the assembly file in qt6.4.2 is the same 2013 file with the same error. But, nailed it. The affected architecture would be anything using dsp extension but not dspr2. #if defined(__mips_dspr2) prepend t1, t2, 8 #else sll t4, t4, 24 srl t1, t1, 8 or t1, t1, t4 #endif Correct is sll t4, t2, 24. I'll take it to qt devs.
Author
Owner

@glassez commented on GitHub (Mar 5, 2023):

I'll take it to qt devs.

👍

@glassez commented on GitHub (Mar 5, 2023): > I'll take it to qt devs. 👍
Author
Owner

@HanabishiRecca commented on GitHub (Mar 12, 2023):

Just mention that in #18630 I use generic x86-64 CPU and still have this issue.

@HanabishiRecca commented on GitHub (Mar 12, 2023): Just mention that in #18630 I use generic x86-64 CPU and still have this issue.
Author
Owner

@mmith9 commented on GitHub (Mar 12, 2023):

Just mention that in #18630 I use generic x86-64 CPU and still have this issue.

Well, let's see if it's the same issue then.

change lines 319 and 320 in requestparse to :

qWarning() << "";
qWarning() << "data" << data;
const QByteArray _mid_view = Utils::ByteArray::midView(data, 0, eohPos);
const QString headers = QString::fromLatin1(_mid_view);
const QByteArray payload = viewWithoutEndingWith(Utils::ByteArray::midView(data, (eohPos + EOH.size()), data.size()), CRLF);
qWarning() << "headers" << headers;
qWarning() << "payload" << payload;

qWarning() << "data&" << (void *)data.data();
qWarning() << "_mid&" << (void *)_mid_view.data();
qWarning() << "head&" << (void *)headers.data();

And tell us what comes along the error msg now

@mmith9 commented on GitHub (Mar 12, 2023): > Just mention that in #18630 I use generic x86-64 CPU and still have this issue. Well, let's see if it's the same issue then. change lines 319 and 320 in requestparse to : qWarning() << ""; qWarning() << "data" << data; const QByteArray _mid_view = Utils::ByteArray::midView(data, 0, eohPos); const QString headers = QString::fromLatin1(_mid_view); const QByteArray payload = viewWithoutEndingWith(Utils::ByteArray::midView(data, (eohPos + EOH.size()), data.size()), CRLF); qWarning() << "headers" << headers; qWarning() << "payload" << payload; qWarning() << "data&" << (void *)data.data(); qWarning() << "_mid&" << (void *)_mid_view.data(); qWarning() << "head&" << (void *)headers.data(); And tell us what comes along the error msg now
Author
Owner

@HanabishiRecca commented on GitHub (Mar 12, 2023):

And tell us what comes along the error msg now

qbittorrent-nox[4533]: data "Content-Disposition: form-data; name=\"urls\"\r\n\r\nmagnet:?xt=urn:btih:6ebb0596f16e8dca6635921c5e125f293e4cecad&dn=archlinux-2023.03.01-x86_64.iso\r\n"
qbittorrent-nox[4533]: headers "Content-Disposition: form-data; name=\"urls\""
qbittorrent-nox[4533]: payload "magnet:?xt=urn:btih:6ebb0596f16e8dca6635921c5e125f293e4cecad&dn=archlinux-2023.03.01-x86_64.iso"
qbittorrent-nox[4533]: data& 0x55aa031a8725
qbittorrent-nox[4533]: _mid& 0x55aa031a8725
qbittorrent-nox[4533]: head& 0x55aa03193940
qbittorrent-nox[4533]: bool Http::RequestParser::parseFormData(const QByteArray&) multipart/form-data header error
qbittorrent-nox[4533]: Http::RequestParser::ParseResult Http::RequestParser::doParse(const QByteArray&) message body parsing error
@HanabishiRecca commented on GitHub (Mar 12, 2023): > And tell us what comes along the error msg now ``` qbittorrent-nox[4533]: data "Content-Disposition: form-data; name=\"urls\"\r\n\r\nmagnet:?xt=urn:btih:6ebb0596f16e8dca6635921c5e125f293e4cecad&dn=archlinux-2023.03.01-x86_64.iso\r\n" qbittorrent-nox[4533]: headers "Content-Disposition: form-data; name=\"urls\"" qbittorrent-nox[4533]: payload "magnet:?xt=urn:btih:6ebb0596f16e8dca6635921c5e125f293e4cecad&dn=archlinux-2023.03.01-x86_64.iso" qbittorrent-nox[4533]: data& 0x55aa031a8725 qbittorrent-nox[4533]: _mid& 0x55aa031a8725 qbittorrent-nox[4533]: head& 0x55aa03193940 qbittorrent-nox[4533]: bool Http::RequestParser::parseFormData(const QByteArray&) multipart/form-data header error qbittorrent-nox[4533]: Http::RequestParser::ParseResult Http::RequestParser::doParse(const QByteArray&) message body parsing error ```
Author
Owner

@mmith9 commented on GitHub (Mar 12, 2023):

Nope, it parses okay. The problem is elsewhere.

@mmith9 commented on GitHub (Mar 12, 2023): Nope, it parses okay. The problem is elsewhere.
Author
Owner

@HanabishiRecca commented on GitHub (Mar 12, 2023):

Thanks anyway.

@HanabishiRecca commented on GitHub (Mar 12, 2023): Thanks anyway.
Author
Owner

@glassez commented on GitHub (Mar 13, 2023):

@HanabishiRecca
Could you also trace headerLines and headersMap after it is filled in?
Unfortunately, I can't reproduce this problem on my PC to sort it out on my own.

@glassez commented on GitHub (Mar 13, 2023): @HanabishiRecca Could you also trace `headerLines` and `headersMap` after it is filled in? Unfortunately, I can't reproduce this problem on my PC to sort it out on my own.
Author
Owner

@HanabishiRecca commented on GitHub (Mar 13, 2023):

@glassez, I went deeper and actually tracked the issue down to Qt6 libs.

I use custom Qt6 headless build for my server. Turns out Qt6 compiled with clang was broken somehow in this regard. Recompiled it with gcc and it works now.

So confirmed: this is 100% some kind of Qt bug.

@HanabishiRecca commented on GitHub (Mar 13, 2023): @glassez, I went deeper and actually tracked the issue down to Qt6 libs. I use custom Qt6 headless build for my server. Turns out Qt6 compiled with `clang` was broken somehow in this regard. Recompiled it with `gcc` and it works now. So confirmed: this is 100% some kind of Qt bug.
Author
Owner

@glassez commented on GitHub (Mar 13, 2023):

So confirmed: this is 100% some kind of Qt bug.

It would be very useful if you reported it to Qt.

@glassez commented on GitHub (Mar 13, 2023): > So confirmed: this is 100% some kind of Qt bug. It would be very useful if you reported it to Qt.
Author
Owner

@luzpaz commented on GitHub (Sep 24, 2023):

@HanabishiRecca is there an upstream ticket yet ?

@luzpaz commented on GitHub (Sep 24, 2023): @HanabishiRecca is there an upstream ticket yet ?
Author
Owner

@HanabishiRecca commented on GitHub (Sep 24, 2023):

No, did not reported it. Because I don't really know what exactly goes wrong, and not sure if any of build/compiler flags affect this behavior.
Also not tested it since, so I am not aware is it actually still reproducible on current Qt6 version.

@HanabishiRecca commented on GitHub (Sep 24, 2023): No, did not reported it. Because I don't really know what exactly goes wrong, and not sure if any of build/compiler flags affect this behavior. Also not tested it since, so I am not aware is it actually still reproducible on current Qt6 version.
Author
Owner

@xavier2k6 commented on GitHub (Sep 25, 2023):

@mmith9 Can you reproduce with latest Qt6.5.x & latest master commit? If you can & still Qt related can you file a report upstream, please.

@xavier2k6 commented on GitHub (Sep 25, 2023): @mmith9 Can you reproduce with latest `Qt6.5.x` & latest `master` commit? If you can & still Qt related can you file a report upstream, please.
Author
Owner

@mmith9 commented on GitHub (Sep 25, 2023):

@mmith9 Can you reproduce with latest Qt6.5.x & latest master commit? If you can & still Qt related can you file a report upstream, please.

I'd rather abstain from cross compiling qt6.5, it was bad enough with 5.15.

Anyway, there seems to be no progress on my report
https://bugreports.qt.io/browse/QTBUG-111740

Also I've downloaded latest qt source, 5.15.10 and 6.5.2 and the bug is still there.

@mmith9 commented on GitHub (Sep 25, 2023): > @mmith9 Can you reproduce with latest `Qt6.5.x` & latest `master` commit? If you can & still Qt related can you file a report upstream, please. I'd rather abstain from cross compiling qt6.5, it was bad enough with 5.15. Anyway, there seems to be no progress on my report https://bugreports.qt.io/browse/QTBUG-111740 Also I've downloaded latest qt source, 5.15.10 and 6.5.2 and the bug is still there.
Author
Owner

@xavier2k6 commented on GitHub (Sep 25, 2023):

@mmith9 Thanks for the response, at least now we have a Qt Report to keep track of.

@xavier2k6 commented on GitHub (Sep 25, 2023): @mmith9 Thanks for the response, at least now we have a Qt Report to keep track of.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/qBittorrent#14392
No description provided.