home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / gnu / utils / bug / 2290 < prev    next >
Encoding:
Text File  |  1992-12-31  |  7.6 KB  |  253 lines

  1. Newsgroups: gnu.utils.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!aktis.COM!jik
  3. From: jik@aktis.COM (Jonathan I. Kamens)
  4. Subject: tar 1.11.1: more allocations without checking return value
  5. Message-ID: <9212302109.AA10686@pad-thai.aktis.com>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: Gnus Not Usenet
  8. Distribution: gnu
  9. Date: Wed, 30 Dec 1992 11:09:26 GMT
  10. Approved: bug-gnu-utils@prep.ai.mit.edu
  11. Lines: 240
  12.  
  13. There are a number of places where memory is allocated without
  14. checking its return value.
  15.  
  16. *** 1.1    1992/12/30 20:58:42
  17. --- create.c    1992/12/30 21:04:49
  18. ***************
  19. *** 943,949 ****
  20.       /* 
  21.        * Make room for our scratch space -- initially is 10 elts long
  22.        */
  23. !     sparsearray = (struct sp_array *) malloc(sp_array_size * sizeof(struct sp_array));
  24.       for (i = 0; i < sp_array_size; i++) {
  25.           sparsearray[i].offset = 0;
  26.           sparsearray[i].numbytes = 0;
  27. --- 943,949 ----
  28.       /* 
  29.        * Make room for our scratch space -- initially is 10 elts long
  30.        */
  31. !     sparsearray = (struct sp_array *) ck_malloc(sp_array_size * sizeof(struct sp_array));
  32.       for (i = 0; i < sp_array_size; i++) {
  33.           sparsearray[i].offset = 0;
  34.           sparsearray[i].numbytes = 0;
  35. ***************
  36. *** 1006,1012 ****
  37.            * realloc the scratch area, since we've run out of room --
  38.            */
  39.               sparsearray = (struct sp_array *) 
  40. !                     realloc(sparsearray,
  41.                            2 * sp_array_size * (sizeof(struct sp_array)));
  42.               sp_array_size *= 2;
  43.           }
  44. --- 1006,1012 ----
  45.            * realloc the scratch area, since we've run out of room --
  46.            */
  47.               sparsearray = (struct sp_array *) 
  48. !                     ck_realloc(sparsearray,
  49.                            2 * sp_array_size * (sizeof(struct sp_array)));
  50.               sp_array_size *= 2;
  51.           }
  52. *** 1.1    1992/12/30 21:06:47
  53. --- diffarch.c    1992/12/30 21:04:48
  54. ***************
  55. *** 542,548 ****
  56.   /*    int        amt_read = 0;*/
  57.       int        size = filesize;
  58.   
  59. !     buf = (char *) malloc(buf_size * sizeof (char));
  60.       
  61.       fill_in_sparse_array();
  62.       
  63. --- 542,548 ----
  64.   /*    int        amt_read = 0;*/
  65.       int        size = filesize;
  66.   
  67. !     buf = (char *) ck_malloc(buf_size * sizeof (char));
  68.       
  69.       fill_in_sparse_array();
  70.       
  71. ***************
  72. *** 563,569 ****
  73.            * take care to not run out of room in our buffer
  74.            */
  75.           while (buf_size < numbytes) {
  76. !             buf = (char *) realloc(buf, buf_size * 2 * sizeof(char));
  77.               buf_size *= 2;
  78.           }
  79.           while (numbytes > RECORDSIZE) {
  80. --- 563,569 ----
  81.            * take care to not run out of room in our buffer
  82.            */
  83.           while (buf_size < numbytes) {
  84. !             buf = (char *) ck_realloc(buf, buf_size * 2 * sizeof(char));
  85.               buf_size *= 2;
  86.           }
  87.           while (numbytes > RECORDSIZE) {
  88. ***************
  89. *** 641,647 ****
  90.        * necessary
  91.        */
  92.       sp_array_size = 10;
  93. !     sparsearray = (struct sp_array *) malloc(sp_array_size * sizeof(struct sp_array));
  94.   
  95.       /*
  96.        * there are at most five of these structures in the header
  97. --- 641,647 ----
  98.        * necessary
  99.        */
  100.       sp_array_size = 10;
  101. !     sparsearray = (struct sp_array *) ck_malloc(sp_array_size * sizeof(struct sp_array));
  102.   
  103.       /*
  104.        * there are at most five of these structures in the header
  105. ***************
  106. *** 673,679 ****
  107.                    *  scratch area - realloc it
  108.                     */
  109.                   sparsearray = (struct sp_array *)
  110. !                     realloc(sparsearray, 
  111.                           sp_array_size*2*sizeof(struct sp_array));
  112.                   sp_array_size *= 2;
  113.               }
  114. --- 673,679 ----
  115.                    *  scratch area - realloc it
  116.                     */
  117.                   sparsearray = (struct sp_array *)
  118. !                     ck_realloc(sparsearray, 
  119.                           sp_array_size*2*sizeof(struct sp_array));
  120.                   sp_array_size *= 2;
  121.               }
  122. *** 1.1    1992/12/30 21:06:12
  123. --- extract.c    1992/12/30 21:04:48
  124. ***************
  125. *** 213,219 ****
  126.         */
  127.        case LF_SPARSE:
  128.            sp_array_size = 10;
  129. !          sparsearray = (struct sp_array *) malloc(sp_array_size * sizeof(struct sp_array));
  130.            for (i = 0; i < SPARSE_IN_HDR; i++) {
  131.                sparsearray[i].offset = 
  132.                    from_oct(1+12, head->header.sp[i].offset);
  133. --- 213,219 ----
  134.         */
  135.        case LF_SPARSE:
  136.            sp_array_size = 10;
  137. !          sparsearray = (struct sp_array *) ck_malloc(sp_array_size * sizeof(struct sp_array));
  138.            for (i = 0; i < SPARSE_IN_HDR; i++) {
  139.                sparsearray[i].offset = 
  140.                    from_oct(1+12, head->header.sp[i].offset);
  141. ***************
  142. *** 243,249 ****
  143.                         * since we've run out of room --
  144.                         */
  145.                            sparsearray = (struct sp_array *) 
  146. !                                  realloc(sparsearray,
  147.                                    2 * sp_array_size * (sizeof(struct sp_array)));
  148.                            sp_array_size *= 2;
  149.                        }
  150. --- 243,249 ----
  151.                         * since we've run out of room --
  152.                         */
  153.                            sparsearray = (struct sp_array *) 
  154. !                                  ck_realloc(sparsearray,
  155.                                    2 * sp_array_size * (sizeof(struct sp_array)));
  156.                            sp_array_size *= 2;
  157.                        }
  158. ***************
  159. *** 355,361 ****
  160.                 * REAL interesting unless we do this.
  161.                 */
  162.                namelen = strlen(skipcrud + current_file_name);
  163. !              name = (char *) malloc((sizeof(char)) * namelen);
  164.                bcopy(skipcrud+current_file_name, name, namelen);
  165.                size = hstat.st_size;
  166.                extract_sparse_file(fd, &size, hstat.st_size, name);
  167. --- 355,361 ----
  168.                 * REAL interesting unless we do this.
  169.                 */
  170.                namelen = strlen(skipcrud + current_file_name);
  171. !              name = (char *) ck_malloc((sizeof(char)) * namelen);
  172.                bcopy(skipcrud+current_file_name, name, namelen);
  173.                size = hstat.st_size;
  174.                extract_sparse_file(fd, &size, hstat.st_size, name);
  175. ***************
  176. *** 652,659 ****
  177.   
  178.           if (f_modified)
  179.             goto set_filestat;
  180. !         tmp = (struct saved_dir_info *) malloc (sizeof (struct saved_dir_info));
  181. !         tmp->path = malloc (strlen (skipcrud + current_file_name) + 1);
  182.           strcpy (tmp->path, skipcrud + current_file_name);
  183.           tmp->mode = hstat.st_mode;
  184.           tmp->atime = hstat.st_atime;
  185. --- 652,659 ----
  186.   
  187.           if (f_modified)
  188.             goto set_filestat;
  189. !         tmp = (struct saved_dir_info *) ck_malloc (sizeof (struct saved_dir_info));
  190. !         tmp->path = ck_malloc (strlen (skipcrud + current_file_name) + 1);
  191.           strcpy (tmp->path, skipcrud + current_file_name);
  192.           tmp->mode = hstat.st_mode;
  193.           tmp->atime = hstat.st_atime;
  194. *** 1.1    1992/12/30 21:01:17
  195. --- list.c    1992/12/30 21:04:47
  196. ***************
  197. *** 387,393 ****
  198.               : head->header.arch_name);
  199.           if (current_file_name)
  200.             free (current_file_name);
  201. !         current_file_name = malloc (strlen (name) + 1);
  202.           strcpy (current_file_name, name);
  203.   
  204.           name = (next_long_link
  205. --- 387,393 ----
  206.               : head->header.arch_name);
  207.           if (current_file_name)
  208.             free (current_file_name);
  209. !         current_file_name = ck_malloc (strlen (name) + 1);
  210.           strcpy (current_file_name, name);
  211.   
  212.           name = (next_long_link
  213. ***************
  214. *** 395,401 ****
  215.               : head->header.arch_linkname);
  216.           if (current_link_name)
  217.             free (current_link_name);
  218. !         current_link_name = malloc (strlen (name) + 1);
  219.           strcpy (current_link_name, name);
  220.           
  221.           next_long_link = next_long_name = 0;
  222. --- 395,401 ----
  223.               : head->header.arch_linkname);
  224.           if (current_link_name)
  225.             free (current_link_name);
  226. !         current_link_name = ck_malloc (strlen (name) + 1);
  227.           strcpy (current_link_name, name);
  228.           
  229.           next_long_link = next_long_name = 0;
  230. *** 1.2    1992/12/14 18:46:23
  231. --- tar.c    1992/12/30 21:04:46
  232. ***************
  233. *** 304,310 ****
  234.   
  235.       /* Set default option values */
  236.       blocking = DEFBLOCKING;        /* From Makefile */
  237. !     ar_files = (char **) malloc (sizeof (char *) * 10);
  238.       ar_files_len = 10;
  239.       n_ar_files = 0;
  240.       cur_ar_file = 0;
  241. --- 304,310 ----
  242.   
  243.       /* Set default option values */
  244.       blocking = DEFBLOCKING;        /* From Makefile */
  245. !     ar_files = (char **) ck_malloc (sizeof (char *) * 10);
  246.       ar_files_len = 10;
  247.       n_ar_files = 0;
  248.       cur_ar_file = 0;
  249.  
  250. Jonathan Kamens                                         jik@MIT.Edu
  251. Aktis, Inc.                                 Moderator, news.answers
  252.  
  253.