--- lbbs/src/user_info_display.c 2025/10/23 13:12:03 1.7 +++ lbbs/src/user_info_display.c 2025/10/23 13:41:47 1.9 @@ -42,17 +42,12 @@ const char *get_astro_name(time_t birthd localtime_r(&birthday, &tm_birth); - if (tm_birth.tm_mon < 1 || tm_birth.tm_mon > 12 || tm_birth.tm_mday < 1 || tm_birth.tm_mday > 31) + if (tm_birth.tm_mday < astro_dates[tm_birth.tm_mon]) { - return astro_names[0]; + return astro_names[tm_birth.tm_mon]; } - if (tm_birth.tm_mday < astro_dates[tm_birth.tm_mon - 1]) - { - return astro_names[tm_birth.tm_mon - 1]; - } - - return astro_names[tm_birth.tm_mon]; + return astro_names[tm_birth.tm_mon + 1]; } static const int user_level_points[] = { @@ -144,6 +139,7 @@ int user_info_display(USER_INFO *p_user_ char str_last_logout_dt[LAST_LOGIN_DT_MAX_LEN + 1]; char login_ip[IP_ADDR_LEN]; int ip_mask_level; + const char *p_action_title; char action_str[LINE_BUFFER_LEN]; const char *user_level_name; char intro_f[BBS_user_intro_max_len]; @@ -204,13 +200,17 @@ int user_info_display(USER_INFO *p_user_ p = action_str; for (i = 0; i < session_cnt; i++) { - if (p + strlen(sessions[i].current_action_title) + 4 >= action_str + sizeof(action_str)) // buffer overflow + p_action_title = (sessions[i].current_action_title != NULL + ? sessions[i].current_action_title + : sessions[i].current_action); + + if (p + strlen(p_action_title) + 4 >= action_str + sizeof(action_str)) // buffer overflow { log_error("action_str of user(uid=%d) truncated at i=%d\n", p_user_info->uid, i); break; } *p++ = '['; - for (q = sessions[i].current_action_title; *q != '\0';) + for (q = p_action_title; *q != '\0';) { *p++ = *q++; }