Support This Project

Changeset 2024

Show
Ignore:
Timestamp:
08/14/08 19:07:23 (4 months ago)
Author:
virdiq
Message:

Fix incorrect assumptions in do_quit that GetGroupByID and GetUserByID always return valid structs.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libwzd-core/wzd_ClientThread.c

    r2023 r2024  
    29132913  ret = send_message(221,context); 
    29142914  { 
    2915     const char * groupname = NULL; 
    2916     wzd_user_t * user; 
    2917     const char * remote_host; 
    2918     struct hostent *h; 
     2915    wzd_user_t * user = NULL; 
     2916    wzd_group_t * group = NULL; 
     2917    struct hostent * h = NULL; 
    29192918    char inet_str[256]; 
    29202919    int af = (context->family == WZD_INET6) ? AF_INET6 : AF_INET; 
     
    29222921    user = GetUserByID(context->userid); 
    29232922 
    2924     if (user->group_num > 0) groupname = GetGroupByID(user->groups[0])->groupname; 
     2923    if (user && user->group_num > 0) { 
     2924      group = GetGroupByID(user->groups[0]); 
     2925    } 
    29252926    inet_str[0] = '\0'; 
    2926     inet_ntop(af,context->hostip,inet_str,sizeof(inet_str)); 
    2927     h = gethostbyaddr((char*)&context->hostip,sizeof(context->hostip),af); 
    2928     if (h==NULL) 
    2929       remote_host = inet_str; 
    2930     else 
    2931       remote_host = h->h_name; 
     2927    inet_ntop(af, context->hostip, inet_str, sizeof(inet_str)); 
     2928    h = gethostbyaddr((char*)&context->hostip, sizeof(context->hostip), af); 
    29322929    log_message("LOGOUT","%s (%s) \"%s\" \"%s\" \"%s\"", 
    2933         remote_host
    2934         inet_str
    2935         user->username
    2936         (groupname)?groupname:"No Group", 
    2937         user->tagline 
     2930        h && h->h_name ? h->h_name : "No hostname"
     2931        *inet_str ? inet_str : "No IP address"
     2932        user && *(user->username) ? user->username : "No username"
     2933        group && *(group->groupname) ? group->groupname : "No groupname", 
     2934        user && *(user->tagline) ? user->tagline : "No tagline" 
    29382935        ); 
    29392936  }