rfc1036 / whois

Intelligent WHOIS client
GNU General Public License v2.0
497 stars 117 forks source link

Harmless memory leak in split_server_port() #165

Closed freedom1b2830 closed 8 months ago

freedom1b2830 commented 9 months ago

source from https://aur.archlinux.org/packages/whois-git version: 5.5.20.r4.gca6d0c6-1

/etc/makepkg.conf

CARCH="x86_64"
CHOST="x86_64-pc-linux-gnu"

CC=clang
CXX=clang++
export CC=clang
export CXX=clang++

CFLAGS="-march=x86-64 -mtune=generic -O0 -g -pipe -fno-plt -fexceptions \
        -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
        -fstack-clash-protection -fcf-protection -fsanitize=address"
CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
LDFLAGS="-Wl,-O0,--sort-common,--as-needed,-z,relro,-z,now"
LTOFLAGS="-flto=auto"
MAKEFLAGS="-j12"
DEBUG_CFLAGS="-g"
DEBUG_CXXFLAGS="$DEBUG_CFLAGS"
whois 64.233.165.113
===================================================================10279==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 15 byte(s) in 1 object(s) allocated from:
    #0 0x55c7bdf83daa in strdup (/usr/bin/whois+0xc7daa) (BuildId: d1e3ef8e62245dd4866d38b0577a8e2de5dc06d9)
    #1 0x55c7be049e91 in split_server_port /usr/src/debug/whois-git/whois/whois.c:1338:12
    #2 0x55c7be048cb3 in handle_query /usr/src/debug/whois-git/whois/whois.c:322:2
    #3 0x55c7be0465f1 in main /usr/src/debug/whois-git/whois/whois.c:300:11
    #4 0x7fa504189ccf in __libc_start_call_main /usr/src/debug/glibc/glibc/csu/../sysdeps/nptl/libc_start_call_main.h:58:16

SUMMARY: AddressSanitizer: 15 byte(s) leaked in 1 allocation(s).
rfc1036 commented 9 months ago

I know, but since whois is a short-lived program I never bothered fixing this. But if you want to fix it for correctness then go for it!

rfc1036 commented 8 months ago

Fixed.