NNTPcache 3.0.2 - AUTHINFO Patch This patch fixes the AUTHINFO code that makes NNTPcache able to authenticate itself to a NNTP server. Mike Mueller head = head; } /* if there's a @ in host there's a user and password */ + + int uppos,hlen; + char user[50] = "",pass[50]="",up[100]="",hostn[100]=""; + hostname = username = password = NULL; - if (strchr(host, '@') != NULL) - { - if ((password = strrchr(host, ':')) != NULL) - *(password++) = '\0'; - else - { + if ((uppos = strchr(host, '@')) != NULL) { + + uppos = (host-uppos); uppos *= -1; + hlen = strlen(host)-uppos; + strncpy(hostn,host+uppos+1,hlen); + strncpy(up,host,uppos); + + if ((uppos = strchr(up, ':')) != NULL) { + uppos = (up-uppos); uppos *= -1; + strncpy(user,up,uppos); + username = user; + strncpy(pass,up+uppos+1,uppos+1); + password = pass; + hostname = hostn; + list->user = Sstrdup (username); + list->pass = Sstrdup (password); + } else { loge (("missing password in %s:%d: %s", file, n, buf)); continue; } - if ((hostname = strrchr(password-2, '@')) != NULL) { - *(hostname++) = '\0'; - username = host; - list->user = Sstrdup (username); - list->pass = Sstrdup (password); - } } else { hostname = host; } + list->host = Sstrdup (hostname); list->us = Sstrdup (us); list->active_timeout = active_timeout;