Magellan Linux

Diff of /trunk/grubby/grubby.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3139 by niro, Tue Jul 7 11:12:00 2020 UTC revision 3149 by niro, Tue Jul 7 11:23:41 2020 UTC
# Line 482  char *grub2ExtractTitle(struct singleLin Line 482  char *grub2ExtractTitle(struct singleLin
482   snprintf(result, resultMaxSize, "%s", ++current);   snprintf(result, resultMaxSize, "%s", ++current);
483    
484   i++;   i++;
485     int result_len = 0;
486   for (; i < line->numElements; ++i) {   for (; i < line->numElements; ++i) {
487   current = line->elements[i].item;   current = line->elements[i].item;
488   current_len = strlen(current);   current_len = strlen(current);
489   current_indent = line->elements[i].indent;   current_indent = line->elements[i].indent;
490   current_indent_len = strlen(current_indent);   current_indent_len = strlen(current_indent);
491    
492   strncat(result, current_indent, current_indent_len);   memcpy(result + result_len, current_indent, current_indent_len);
493     result_len += current_indent_len;
494    
495   if (current[current_len - 1] != quote_char) {   if (current[current_len - 1] != quote_char) {
496   strncat(result, current, current_len);   memcpy(result + result_len, current_indent,
497           current_indent_len);
498     result_len += current_len;
499   } else {   } else {
500   strncat(result, current, current_len - 1);   memcpy(result + result_len, current_indent,
501           current_indent_len);
502     result_len += (current_len - 1);
503   break;   break;
504   }   }
505   }   }
506     result[result_len] = '\0';
507   return result;   return result;
508  }  }
509    
# Line 1440  static struct grubConfig *readConfig(con Line 1448  static struct grubConfig *readConfig(con
1448   extras = malloc(len + 1);   extras = malloc(len + 1);
1449   *extras = '\0';   *extras = '\0';
1450    
1451     int buf_len = 0;
1452   /* get title. */   /* get title. */
1453   for (int i = 0; i < line->numElements; i++) {   for (int i = 0; i < line->numElements; i++) {
1454   if (!strcmp   if (!strcmp
# Line 1456  static struct grubConfig *readConfig(con Line 1465  static struct grubConfig *readConfig(con
1465    
1466   len = strlen(title);   len = strlen(title);
1467   if (title[len - 1] == quote_char) {   if (title[len - 1] == quote_char) {
1468   strncat(buf, title, len - 1);   memcpy(buf + buf_len, title, len - 1);
1469     buf_len += (len - 1);
1470   break;   break;
1471   } else {   } else {
1472   strcat(buf, title);   memcpy(buf + buf_len, title, len);
1473   strcat(buf, line->elements[i].indent);   buf_len += len;
1474     len = strlen(line->elements[i].indent);
1475     memcpy(buf + buf_len, line->elements[i].indent, len);
1476     buf_len += len;
1477   }   }
1478   }   }
1479     buf[buf_len] = '\0';
1480    
1481   /* get extras */   /* get extras */
1482   int count = 0;   int count = 0;
# Line 5212  int main(int argc, const char **argv) Line 5226  int main(int argc, const char **argv)
5226   exit(1);   exit(1);
5227   }   }
5228   saved_command_line[0] = '\0';   saved_command_line[0] = '\0';
5229     int cmdline_len = 0, arg_len;
5230   for (int j = 1; j < argc; j++) {   for (int j = 1; j < argc; j++) {
5231   strcat(saved_command_line, argv[j]);   arg_len = strlen(argv[j]);
5232   strncat(saved_command_line, j == argc - 1 ? "" : " ", 1);   memcpy(saved_command_line + cmdline_len, argv[j], arg_len);
5233     cmdline_len += arg_len;
5234     if (j != argc - 1) {
5235     memcpy(saved_command_line + cmdline_len, " ", 1);
5236     cmdline_len++;
5237     }
5238    
5239   }   }
5240     saved_command_line[cmdline_len] = '\0';
5241    
5242   optCon = poptGetContext("grubby", argc, argv, options, 0);   optCon = poptGetContext("grubby", argc, argv, options, 0);
5243   poptReadDefaultConfig(optCon, 1);   poptReadDefaultConfig(optCon, 1);

Legend:
Removed from v.3139  
changed lines
  Added in v.3149