Changeset 9b02fa65 in rtems
- Timestamp:
- 03/27/02 14:44:55 (22 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 78287f41
- Parents:
- 6d00095
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/exec/libnetworking/ChangeLog
r6d00095 r9b02fa65 1 2002-03-27 Thomas.Doerfler@imd-systems.de 2 3 * PR144 4 * nfs/bootp_subr.c bootpc_init(): Performs a write to memory address 5 0 when called for the first time. This is done when trying to clear 6 the variable "dhcp_hostname". 7 1 8 2002-03-27 Ilya Alexeev <ilya@continuum.ru> 2 9 -
c/src/exec/libnetworking/nfs/bootp_subr.c
r6d00095 r9b02fa65 262 262 #endif 263 263 264 /* 265 * - determine space needed to store src string 266 * - allocate or reallocate dst, so that string fits in 267 * - copy string from src to dest 268 */ 269 void *bootp_strdup_realloc(char *dst,const char *src) 270 { 271 size_t len; 272 void *realloc(void * __r, size_t __size); 273 274 if (dst == NULL) { 275 /* first allocation, simply use strdup */ 276 dst = strdup(src); 277 } 278 else { 279 /* already allocated, so use realloc/strcpy */ 280 len = strlen(src) + 1; 281 dst = realloc(dst,len); 282 if (dst != NULL) { 283 strcpy(dst,src); 284 } 285 } 286 return dst; 287 } 288 264 289 int 265 290 bootpc_call(call,reply,procp) … … 695 720 static struct sockaddr_in dhcp_netmask; 696 721 static struct sockaddr_in dhcp_gw; 697 static char *dhcp_hostname ;722 static char *dhcp_hostname = NULL; 698 723 699 724 static void … … 802 827 panic("Can't set host name"); 803 828 printf("Hostname is %s\n", p); 804 dhcp_hostname = strdup(p);829 dhcp_hostname = bootp_strdup_realloc(dhcp_hostname,p); 805 830 break; 806 831 … … 818 843 /* Domain name */ 819 844 if (p[0]) { 820 rtems_bsdnet_domain_name = strdup (p); 845 rtems_bsdnet_domain_name = 846 bootp_strdup_realloc(rtems_bsdnet_domain_name,p); 821 847 printf("Domain name is %s\n", rtems_bsdnet_domain_name); 822 848 } … … 853 879 /* DHCP server name option */ 854 880 if (p[0]) 855 rtems_bsdnet_bootp_server_name = strdup (p); 881 rtems_bsdnet_bootp_server_name = 882 bootp_strdup_realloc(rtems_bsdnet_bootp_server_name,p); 856 883 break; 857 884 … … 859 886 /* DHCP bootfile option */ 860 887 if (p[0]) 861 rtems_bsdnet_bootp_boot_file_name = strdup (p); 888 rtems_bsdnet_bootp_boot_file_name = 889 bootp_strdup_realloc(rtems_bsdnet_bootp_boot_file_name,p); 862 890 break; 863 891 … … 905 933 } 906 934 907 memset(dhcp_hostname, 0, sizeof(dhcp_hostname));908 935 dhcp_hostname = NULL; 936 909 937 /* 910 938 * Find a network interface. … … 1011 1039 else { 1012 1040 if (reply.file[0]) 1013 rtems_bsdnet_bootp_boot_file_name = strdup (reply.file); 1041 rtems_bsdnet_bootp_boot_file_name = 1042 bootp_strdup_realloc(rtems_bsdnet_bootp_boot_file_name,reply.file); 1014 1043 } 1015 1044 if (dhcpOptionOverload & 2) { … … 1018 1047 else { 1019 1048 if (reply.sname[0]) 1020 rtems_bsdnet_bootp_server_name = strdup (reply.sname); 1049 rtems_bsdnet_bootp_server_name = 1050 bootp_strdup_realloc(rtems_bsdnet_bootp_server_name,reply.sname); 1021 1051 } 1022 1052 if (rtems_bsdnet_bootp_server_name) -
c/src/libnetworking/ChangeLog
r6d00095 r9b02fa65 1 2002-03-27 Thomas.Doerfler@imd-systems.de 2 3 * PR144 4 * nfs/bootp_subr.c bootpc_init(): Performs a write to memory address 5 0 when called for the first time. This is done when trying to clear 6 the variable "dhcp_hostname". 7 1 8 2002-03-27 Ilya Alexeev <ilya@continuum.ru> 2 9 -
c/src/libnetworking/nfs/bootp_subr.c
r6d00095 r9b02fa65 262 262 #endif 263 263 264 /* 265 * - determine space needed to store src string 266 * - allocate or reallocate dst, so that string fits in 267 * - copy string from src to dest 268 */ 269 void *bootp_strdup_realloc(char *dst,const char *src) 270 { 271 size_t len; 272 void *realloc(void * __r, size_t __size); 273 274 if (dst == NULL) { 275 /* first allocation, simply use strdup */ 276 dst = strdup(src); 277 } 278 else { 279 /* already allocated, so use realloc/strcpy */ 280 len = strlen(src) + 1; 281 dst = realloc(dst,len); 282 if (dst != NULL) { 283 strcpy(dst,src); 284 } 285 } 286 return dst; 287 } 288 264 289 int 265 290 bootpc_call(call,reply,procp) … … 695 720 static struct sockaddr_in dhcp_netmask; 696 721 static struct sockaddr_in dhcp_gw; 697 static char *dhcp_hostname ;722 static char *dhcp_hostname = NULL; 698 723 699 724 static void … … 802 827 panic("Can't set host name"); 803 828 printf("Hostname is %s\n", p); 804 dhcp_hostname = strdup(p);829 dhcp_hostname = bootp_strdup_realloc(dhcp_hostname,p); 805 830 break; 806 831 … … 818 843 /* Domain name */ 819 844 if (p[0]) { 820 rtems_bsdnet_domain_name = strdup (p); 845 rtems_bsdnet_domain_name = 846 bootp_strdup_realloc(rtems_bsdnet_domain_name,p); 821 847 printf("Domain name is %s\n", rtems_bsdnet_domain_name); 822 848 } … … 853 879 /* DHCP server name option */ 854 880 if (p[0]) 855 rtems_bsdnet_bootp_server_name = strdup (p); 881 rtems_bsdnet_bootp_server_name = 882 bootp_strdup_realloc(rtems_bsdnet_bootp_server_name,p); 856 883 break; 857 884 … … 859 886 /* DHCP bootfile option */ 860 887 if (p[0]) 861 rtems_bsdnet_bootp_boot_file_name = strdup (p); 888 rtems_bsdnet_bootp_boot_file_name = 889 bootp_strdup_realloc(rtems_bsdnet_bootp_boot_file_name,p); 862 890 break; 863 891 … … 905 933 } 906 934 907 memset(dhcp_hostname, 0, sizeof(dhcp_hostname));908 935 dhcp_hostname = NULL; 936 909 937 /* 910 938 * Find a network interface. … … 1011 1039 else { 1012 1040 if (reply.file[0]) 1013 rtems_bsdnet_bootp_boot_file_name = strdup (reply.file); 1041 rtems_bsdnet_bootp_boot_file_name = 1042 bootp_strdup_realloc(rtems_bsdnet_bootp_boot_file_name,reply.file); 1014 1043 } 1015 1044 if (dhcpOptionOverload & 2) { … … 1018 1047 else { 1019 1048 if (reply.sname[0]) 1020 rtems_bsdnet_bootp_server_name = strdup (reply.sname); 1049 rtems_bsdnet_bootp_server_name = 1050 bootp_strdup_realloc(rtems_bsdnet_bootp_server_name,reply.sname); 1021 1051 } 1022 1052 if (rtems_bsdnet_bootp_server_name) -
cpukit/libnetworking/ChangeLog
r6d00095 r9b02fa65 1 2002-03-27 Thomas.Doerfler@imd-systems.de 2 3 * PR144 4 * nfs/bootp_subr.c bootpc_init(): Performs a write to memory address 5 0 when called for the first time. This is done when trying to clear 6 the variable "dhcp_hostname". 7 1 8 2002-03-27 Ilya Alexeev <ilya@continuum.ru> 2 9 -
cpukit/libnetworking/nfs/bootp_subr.c
r6d00095 r9b02fa65 262 262 #endif 263 263 264 /* 265 * - determine space needed to store src string 266 * - allocate or reallocate dst, so that string fits in 267 * - copy string from src to dest 268 */ 269 void *bootp_strdup_realloc(char *dst,const char *src) 270 { 271 size_t len; 272 void *realloc(void * __r, size_t __size); 273 274 if (dst == NULL) { 275 /* first allocation, simply use strdup */ 276 dst = strdup(src); 277 } 278 else { 279 /* already allocated, so use realloc/strcpy */ 280 len = strlen(src) + 1; 281 dst = realloc(dst,len); 282 if (dst != NULL) { 283 strcpy(dst,src); 284 } 285 } 286 return dst; 287 } 288 264 289 int 265 290 bootpc_call(call,reply,procp) … … 695 720 static struct sockaddr_in dhcp_netmask; 696 721 static struct sockaddr_in dhcp_gw; 697 static char *dhcp_hostname ;722 static char *dhcp_hostname = NULL; 698 723 699 724 static void … … 802 827 panic("Can't set host name"); 803 828 printf("Hostname is %s\n", p); 804 dhcp_hostname = strdup(p);829 dhcp_hostname = bootp_strdup_realloc(dhcp_hostname,p); 805 830 break; 806 831 … … 818 843 /* Domain name */ 819 844 if (p[0]) { 820 rtems_bsdnet_domain_name = strdup (p); 845 rtems_bsdnet_domain_name = 846 bootp_strdup_realloc(rtems_bsdnet_domain_name,p); 821 847 printf("Domain name is %s\n", rtems_bsdnet_domain_name); 822 848 } … … 853 879 /* DHCP server name option */ 854 880 if (p[0]) 855 rtems_bsdnet_bootp_server_name = strdup (p); 881 rtems_bsdnet_bootp_server_name = 882 bootp_strdup_realloc(rtems_bsdnet_bootp_server_name,p); 856 883 break; 857 884 … … 859 886 /* DHCP bootfile option */ 860 887 if (p[0]) 861 rtems_bsdnet_bootp_boot_file_name = strdup (p); 888 rtems_bsdnet_bootp_boot_file_name = 889 bootp_strdup_realloc(rtems_bsdnet_bootp_boot_file_name,p); 862 890 break; 863 891 … … 905 933 } 906 934 907 memset(dhcp_hostname, 0, sizeof(dhcp_hostname));908 935 dhcp_hostname = NULL; 936 909 937 /* 910 938 * Find a network interface. … … 1011 1039 else { 1012 1040 if (reply.file[0]) 1013 rtems_bsdnet_bootp_boot_file_name = strdup (reply.file); 1041 rtems_bsdnet_bootp_boot_file_name = 1042 bootp_strdup_realloc(rtems_bsdnet_bootp_boot_file_name,reply.file); 1014 1043 } 1015 1044 if (dhcpOptionOverload & 2) { … … 1018 1047 else { 1019 1048 if (reply.sname[0]) 1020 rtems_bsdnet_bootp_server_name = strdup (reply.sname); 1049 rtems_bsdnet_bootp_server_name = 1050 bootp_strdup_realloc(rtems_bsdnet_bootp_server_name,reply.sname); 1021 1051 } 1022 1052 if (rtems_bsdnet_bootp_server_name)
Note: See TracChangeset
for help on using the changeset viewer.