- Timestamp:
- Dec 30, 2004, 3:38:59 PM (20 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 74037d9
- Parents:
- fe39450
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
message.c
rba9f236 r8298425 19 19 owl_message_set_direction_none(m); 20 20 m->delete=0; 21 strcpy(m->hostname,"");21 m->hostname=owl_strdup(""); 22 22 m->zwriteline=strdup(""); 23 23 m->invalid_format=1; … … 463 463 } 464 464 #endif 465 466 void owl_message_set_hostname(owl_message *m, char *hostname) 467 { 468 if (m==NULL) return; 469 if (m->hostname!=NULL) { 470 owl_free(m->hostname); 471 } 472 m->hostname=owl_strdup(hostname); 473 } 465 474 466 475 char *owl_message_get_hostname(owl_message *m) … … 815 824 hent=gethostbyaddr((char *) &(n->z_uid.zuid_addr), sizeof(n->z_uid.zuid_addr), AF_INET); 816 825 if (hent && hent->h_name) { 817 strcpy(m->hostname, hent->h_name);826 owl_message_set_hostname(m, hent->h_name); 818 827 } else { 819 strcpy(m->hostname, inet_ntoa(n->z_sender_addr));828 owl_message_set_hostname(m, inet_ntoa(n->z_sender_addr)); 820 829 } 821 830 } … … 870 879 /* save the hostname */ 871 880 owl_function_debugmsg("create_pseudo_login: host is %s", host ? host : ""); 872 strcpy(m->hostname, host ? host : "");881 owl_message_set_hostname(m, host ? host : ""); 873 882 owl_free(longuser); 874 883 } … … 878 887 owl_zwrite z; 879 888 int ret; 889 char hostbuff[5000]; 880 890 881 891 owl_message_init(m); … … 901 911 902 912 /* save the hostname */ 903 ret=gethostname(m->hostname, MAXHOSTNAMELEN); 913 ret=gethostname(hostbuff, MAXHOSTNAMELEN); 914 hostbuff[MAXHOSTNAMELEN]='\0'; 904 915 if (ret) { 905 strcpy(m->hostname, "localhost"); 906 } 907 916 owl_message_set_hostname(m, "localhost"); 917 } else { 918 owl_message_set_hostname(m, hostbuff); 919 } 908 920 owl_zwrite_free(&z); 909 921 }
Note: See TracChangeset
for help on using the changeset viewer.