Skip to content
  • Michal Privoznik's avatar
    sockets.c: Avoid leaking overridden server name in connect_socket() · 7e7f92e6
    Michal Privoznik authored
    The connect_socket() can be called with @server argument being
    set to a hostname that's different to "localhost" but in fact is
    localhost. In this case, and when @allow_server_override is set,
    the function connects to "localhost". Well, the leak exists
    because in aforementioned case the @server variable is
    overwritten. And since it is plain 'char *' it has to be
    strdup()-ed. But switching it to 'const char *', it can be set to
    "localhost" literal. Similarly, @port
    
     is constant and unchanged
    withing the function and thus should be type of 'const char *'.
    
    Signed-off-by: default avatarMichal Privoznik <mprivozn@redhat.com>
    7e7f92e6