Print this page
locale stuff should use libc safe lmalloc.  Other fixes from tests.

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libc/port/locale/ldpart.c
          +++ new/usr/src/lib/libc/port/locale/ldpart.c
↓ open down ↓ 30 lines elided ↑ open up ↑
  31   31  #include <sys/types.h>
  32   32  #include <sys/stat.h>
  33   33  #include <errno.h>
  34   34  #include <fcntl.h>
  35   35  #include <limits.h>
  36   36  #include <stdlib.h>
  37   37  #include <string.h>
  38   38  #include <unistd.h>
  39   39  #include <stdio.h>
  40   40  
       41 +#include "libc.h"
  41   42  #include "ldpart.h"
  42   43  #include "setlocale.h"
  43   44  
  44   45  static int split_lines(char *, const char *);
  45   46  
  46   47  int
  47   48  __part_load_locale(const char *name,
  48   49      char **locale_buf, const char *category_filename,
  49   50      int locale_buf_size_max, int locale_buf_size_min,
  50   51      const char **dst_localebuf)
↓ open down ↓ 17 lines elided ↑ open up ↑
  68   69  
  69   70          if ((fd = open(filename, O_RDONLY)) < 0)
  70   71                  return (_LDP_ERROR);
  71   72          if (fstat(fd, &st) != 0)
  72   73                  goto bad_locale;
  73   74          if (st.st_size <= 0) {
  74   75                  errno = EINVAL;
  75   76                  goto bad_locale;
  76   77          }
  77   78          bufsize = namesize + st.st_size;
  78      -        if ((lbuf = malloc(bufsize)) == NULL) {
       79 +        if ((lbuf = libc_malloc(bufsize)) == NULL) {
  79   80                  errno = ENOMEM;
  80   81                  goto bad_locale;
  81   82          }
  82   83          (void) strcpy(lbuf, name);
  83   84          p = lbuf + namesize;
  84   85          plim = p + st.st_size;
  85   86          if (read(fd, p, (size_t)st.st_size) != st.st_size)
  86   87                  goto bad_lbuf;
  87   88          /*
  88   89           * Parse the locale file into localebuf.
↓ open down ↓ 53 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX