Skip to content

Exports conflicting turbojpeg functions #729

Description

@net147

If you'd like to put out an incentive for fixing this bug, you can do so at https://issuehunt.io/r/LibVNC/libvncserver

Describe the bug
libvncserver.so exports turbojpeg functions. If an application links to both libvncserver and libjpeg-turbo (either directly or indirectly through another library), it can cause the application to unexpectedly call the libvncserver implementation instead of the libjpeg-turbo implementation.

To Reproduce
test.c

Compile and run the attached test program:
gcc test.c -o test -lvncserver -lturbojpeg -ldl
./test

The exported symbols can also be seen using readelf:
readelf -Ws /usr/lib/libvncserver.so | awk '$7 != "UND" && $8 ~ /^tj/'

213: 0000000000035370 135 FUNC GLOBAL DEFAULT 10 tjDecompress
225: 00000000000348b0 206 FUNC GLOBAL DEFAULT 10 tjCompress
243: 0000000000034350 1363 FUNC GLOBAL DEFAULT 10 tjCompress2
262: 0000000000034100 183 FUNC GLOBAL DEFAULT 10 tjDestroy
294: 0000000000034210 63 FUNC GLOBAL DEFAULT 10 tjInitCompress
328: 0000000000034d00 58 FUNC GLOBAL DEFAULT 10 tjDecompressHeader
354: 0000000000034980 63 FUNC GLOBAL DEFAULT 10 tjInitDecompress
423: 0000000000034da0 1483 FUNC GLOBAL DEFAULT 10 tjDecompress2
439: 00000000000349c0 821 FUNC GLOBAL DEFAULT 10 tjDecompressHeader2
447: 0000000000034250 158 FUNC GLOBAL DEFAULT 10 tjBufSize
516: 0000000000034d40 82 FUNC GLOBAL DEFAULT 10 tjGetScalingFactors
528: 00000000000340f0 12 FUNC GLOBAL DEFAULT 10 tjGetErrorStr

Expected Output

Application tjCompress2 = 0x7f2a6f7ec1b0
libvncserver.so tjCompress2 = (nil)
libturbojpeg.so tjCompress2 = 0x7f2a6f7ec1b0

Actual Output

Application tjCompress2 = 0x7f2e6568a350
libvncserver.so tjCompress2 = 0x7f2e6568a350
libturbojpeg.so tjCompress2 = 0x7f2e6560a1b0

Application resolves to libvncserver's symbol

Your environment (please complete the following information):

  • OS and version: Arch Linux x86-64
  • Compiler and version: gcc (GCC) 16.1.1 20260430

Additional context
It resulted in a crash in reframe v1.10.5 as described in AlynxZhou/reframe#13

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions