Changeset 9b02fa65 in rtems


Ignore:
Timestamp:
Mar 27, 2002, 2:44:55 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
78287f41
Parents:
6d00095
Message:

2002-03-27 Thomas.Doerfler@…

  • PR144
  • nfs/bootp_subr.c bootpc_init(): Performs a write to memory address 0 when called for the first time. This is done when trying to clear the variable "dhcp_hostname".
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/libnetworking/ChangeLog

    r6d00095 r9b02fa65  
     12002-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
    182002-03-27      Ilya Alexeev <ilya@continuum.ru>
    29
  • c/src/exec/libnetworking/nfs/bootp_subr.c

    r6d00095 r9b02fa65  
    262262#endif
    263263
     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 */
     269void *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
    264289int
    265290bootpc_call(call,reply,procp)
     
    695720static struct sockaddr_in dhcp_netmask;
    696721static struct sockaddr_in dhcp_gw;
    697 static char *dhcp_hostname;
     722static char *dhcp_hostname = NULL;
    698723
    699724static void
     
    802827        panic("Can't set host name");
    803828      printf("Hostname is %s\n", p);
    804       dhcp_hostname = strdup(p);
     829      dhcp_hostname = bootp_strdup_realloc(dhcp_hostname,p);
    805830      break;
    806831
     
    818843      /* Domain name */
    819844      if (p[0]) {
    820         rtems_bsdnet_domain_name = strdup (p);
     845        rtems_bsdnet_domain_name =
     846          bootp_strdup_realloc(rtems_bsdnet_domain_name,p);
    821847        printf("Domain name is %s\n", rtems_bsdnet_domain_name);
    822848      }
     
    853879      /* DHCP server name option */
    854880      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);
    856883      break;
    857884
     
    859886      /* DHCP bootfile option */
    860887      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);
    862890      break;
    863891
     
    905933    }
    906934
    907   memset(dhcp_hostname, 0, sizeof(dhcp_hostname));
    908  
     935  dhcp_hostname = NULL;
     936
    909937  /*
    910938   * Find a network interface.
     
    10111039  else {
    10121040    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);
    10141043  }
    10151044  if (dhcpOptionOverload & 2) {
     
    10181047  else {
    10191048    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);
    10211051  }
    10221052  if (rtems_bsdnet_bootp_server_name)
  • c/src/libnetworking/ChangeLog

    r6d00095 r9b02fa65  
     12002-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
    182002-03-27      Ilya Alexeev <ilya@continuum.ru>
    29
  • c/src/libnetworking/nfs/bootp_subr.c

    r6d00095 r9b02fa65  
    262262#endif
    263263
     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 */
     269void *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
    264289int
    265290bootpc_call(call,reply,procp)
     
    695720static struct sockaddr_in dhcp_netmask;
    696721static struct sockaddr_in dhcp_gw;
    697 static char *dhcp_hostname;
     722static char *dhcp_hostname = NULL;
    698723
    699724static void
     
    802827        panic("Can't set host name");
    803828      printf("Hostname is %s\n", p);
    804       dhcp_hostname = strdup(p);
     829      dhcp_hostname = bootp_strdup_realloc(dhcp_hostname,p);
    805830      break;
    806831
     
    818843      /* Domain name */
    819844      if (p[0]) {
    820         rtems_bsdnet_domain_name = strdup (p);
     845        rtems_bsdnet_domain_name =
     846          bootp_strdup_realloc(rtems_bsdnet_domain_name,p);
    821847        printf("Domain name is %s\n", rtems_bsdnet_domain_name);
    822848      }
     
    853879      /* DHCP server name option */
    854880      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);
    856883      break;
    857884
     
    859886      /* DHCP bootfile option */
    860887      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);
    862890      break;
    863891
     
    905933    }
    906934
    907   memset(dhcp_hostname, 0, sizeof(dhcp_hostname));
    908  
     935  dhcp_hostname = NULL;
     936
    909937  /*
    910938   * Find a network interface.
     
    10111039  else {
    10121040    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);
    10141043  }
    10151044  if (dhcpOptionOverload & 2) {
     
    10181047  else {
    10191048    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);
    10211051  }
    10221052  if (rtems_bsdnet_bootp_server_name)
  • cpukit/libnetworking/ChangeLog

    r6d00095 r9b02fa65  
     12002-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
    182002-03-27      Ilya Alexeev <ilya@continuum.ru>
    29
  • cpukit/libnetworking/nfs/bootp_subr.c

    r6d00095 r9b02fa65  
    262262#endif
    263263
     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 */
     269void *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
    264289int
    265290bootpc_call(call,reply,procp)
     
    695720static struct sockaddr_in dhcp_netmask;
    696721static struct sockaddr_in dhcp_gw;
    697 static char *dhcp_hostname;
     722static char *dhcp_hostname = NULL;
    698723
    699724static void
     
    802827        panic("Can't set host name");
    803828      printf("Hostname is %s\n", p);
    804       dhcp_hostname = strdup(p);
     829      dhcp_hostname = bootp_strdup_realloc(dhcp_hostname,p);
    805830      break;
    806831
     
    818843      /* Domain name */
    819844      if (p[0]) {
    820         rtems_bsdnet_domain_name = strdup (p);
     845        rtems_bsdnet_domain_name =
     846          bootp_strdup_realloc(rtems_bsdnet_domain_name,p);
    821847        printf("Domain name is %s\n", rtems_bsdnet_domain_name);
    822848      }
     
    853879      /* DHCP server name option */
    854880      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);
    856883      break;
    857884
     
    859886      /* DHCP bootfile option */
    860887      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);
    862890      break;
    863891
     
    905933    }
    906934
    907   memset(dhcp_hostname, 0, sizeof(dhcp_hostname));
    908  
     935  dhcp_hostname = NULL;
     936
    909937  /*
    910938   * Find a network interface.
     
    10111039  else {
    10121040    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);
    10141043  }
    10151044  if (dhcpOptionOverload & 2) {
     
    10181047  else {
    10191048    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);
    10211051  }
    10221052  if (rtems_bsdnet_bootp_server_name)
Note: See TracChangeset for help on using the changeset viewer.