Bug 1464635 - SEGV in chm_http
SEGV in chm_http
Status: NEW
Product: Fedora
Classification: Fedora
Component: chmlib (Show other bugs)
27
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Peter Lemenkov
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-06-23 22:26 EDT by Przemek Klosowski
Modified: 2017-11-16 14:51 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
chm file to demonstrate the crash (240.25 KB, application/octet-stream)
2017-06-23 22:26 EDT, Przemek Klosowski
no flags Details

  None (edit)
Description Przemek Klosowski 2017-06-23 22:26:26 EDT
Created attachment 1291319 [details]
chm file to demonstrate the crash

Description of problem:
chm_http gets frequent SEGV crashes

Version-Release number of selected component (if applicable):
chmlib-0.40-13.fc24.x86_64


How reproducible: every time


Steps to Reproduce:
1. run on a random .chm file:    chm_http e.chm
2. point browser to localhost:8080
3. click on links in the file

Actual results: segv crash
0x0000555555555654 in service_request (fd=<optimized out>, file=0x555555768010) at chm_http.c:357
357	    if (strncmp(end+1, "HTTP", 4) == 0)


Expected results: no crash, correct operation


Additional info: I suspect that it doesn't matter which .CHM file to use, but just in case, I include the one I tried to read
Comment 1 Przemek Klosowski 2017-06-23 22:36:35 EDT
The code in service_request():356 :
    end = strrchr(buffer, ' ');
    if (strncmp(end+1, "HTTP", 4) == 0)

is incorrect because strrchr() can return NULL if the string is not found, causing the NULL dereference in the next line.

I observed this when buffer is read as empty (i.e. it contains only NULLs).
The correct code should probably explicitly check for that null:

    end = strrchr(buffer, ' ');
    if (!end && strncmp(end+1, "HTTP", 4) == 0)

although in that case service_request() will produce a CONTENT_500 and I am not sure if that's warranted---it's unclear when the empty buffer will appear.
Comment 2 Fedora End Of Life 2017-11-16 14:29:35 EST
This message is a reminder that Fedora 25 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 25. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '25'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 25 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.
Comment 3 Przemek Klosowski 2017-11-16 14:51:11 EST
Still a problem in F27 chmlib-0.40-16.fc27.x86_64

Note You need to log in before you can comment on or make changes to this bug.