--- gcc-13.2.0/gcc/config/mips/t-elf	2023-07-27 17:13:04.000000000 +0900
+++ gcc-13.2.0-fix/gcc/config/mips/t-elf	2023-10-08 00:08:17.156002109 +0900
@@ -18,6 +18,6 @@
 
 # Build the libraries for both hard and soft floating point
 
-MULTILIB_OPTIONS = msoft-float EL/EB
-MULTILIB_DIRNAMES = soft-float el eb
-MULTILIB_MATCHES = EL=mel EB=meb msingle-float=m4650
+MULTILIB_OPTIONS = mabi=32 EL/EB
+MULTILIB_DIRNAMES = 32 el eb
+MULTILIB_MATCHES = EL=mel EB=meb
--- gcc-13.2.0/libcpp/expr.cc	2023-07-27 17:13:07.000000000 +0900
+++ gcc-13.2.0-fix/libcpp/expr.cc	2023-10-08 00:09:53.019334021 +0900
@@ -819,10 +819,10 @@
 
 	  if (CPP_OPTION (pfile, c99))
             cpp_warning_with_line (pfile, CPP_W_LONG_LONG, virtual_location,
-				   0, message);
+				   0, "%s", message);
           else
             cpp_pedwarning_with_line (pfile, CPP_W_LONG_LONG,
-				      virtual_location, 0, message);
+				      virtual_location, 0, "%s", message);
         }
 
       if ((result & CPP_N_SIZE_T) == CPP_N_SIZE_T
@@ -832,7 +832,7 @@
 				? N_("use of C++23 %<size_t%> integer constant")
 				: N_("use of C++23 %<make_signed_t<size_t>%> integer constant");
 	  cpp_warning_with_line (pfile, CPP_W_SIZE_T_LITERALS,
-				 virtual_location, 0, message);
+				 virtual_location, 0, "%s", message);
        }
 
       result |= CPP_N_INTEGER;
--- gcc-13.2.0/libcpp/macro.cc	2023-07-27 17:13:07.000000000 +0900
+++ gcc-13.2.0-fix/libcpp/macro.cc	2023-10-08 00:11:05.702666276 +0900
@@ -183,7 +183,7 @@
 	if (m_state == 2 && token->type == CPP_PASTE)
 	  {
 	    cpp_error_at (m_pfile, CPP_DL_ERROR, token->src_loc,
-			  vaopt_paste_error);
+			  "%s", vaopt_paste_error);
 	    return ERROR;
 	  }
 	/* Advance states before further considering this token, in
@@ -212,7 +212,7 @@
 		if (was_paste)
 		  {
 		    cpp_error_at (m_pfile, CPP_DL_ERROR, token->src_loc,
-				  vaopt_paste_error);
+				  "%s", vaopt_paste_error);
 		    return ERROR;
 		  }
 
@@ -3701,7 +3701,7 @@
 	     function-like macros, but not at the end.  */
 	  if (following_paste_op)
 	    {
-	      cpp_error (pfile, CPP_DL_ERROR, paste_op_error_msg);
+	      cpp_error (pfile, CPP_DL_ERROR, "%s", paste_op_error_msg);
 	      goto out;
 	    }
 	  if (!vaopt_tracker.completed ())
@@ -3716,7 +3716,7 @@
 	     function-like macros, but not at the beginning.  */
 	  if (macro->count == 1)
 	    {
-	      cpp_error (pfile, CPP_DL_ERROR, paste_op_error_msg);
+	      cpp_error (pfile, CPP_DL_ERROR, "%s", paste_op_error_msg);
 	      goto out;
 	    }
 
--- gcc-13.2.0/gcc/c/c-typeck.cc	2023-07-27 17:13:04.000000000 +0900
+++ gcc-13.2.0-fix/gcc/c/c-typeck.cc	2023-10-08 00:24:30.402654349 +0900
@@ -3795,7 +3795,7 @@
       else if ((invalid_func_diag =
 		targetm.calls.invalid_arg_for_unprototyped_fn (typelist, fundecl, val)))
 	{
-	  error (invalid_func_diag);
+	  error ("%s", invalid_func_diag);
 	  return -1;
 	}
       else if (TREE_CODE (val) == ADDR_EXPR && reject_gcc_builtin (val))
@@ -4565,7 +4565,7 @@
   if ((invalid_op_diag
        = targetm.invalid_unary_op (code, TREE_TYPE (xarg))))
     {
-      error_at (location, invalid_op_diag);
+      error_at (location, "%s", invalid_op_diag);
       return error_mark_node;
     }

@@ -6752,7 +6752,7 @@
   location_t exploc = expansion_point_location_if_in_system_header (loc);

   /* The gmsgid may be a format string with %< and %>. */
-  warned = warning_at (exploc, opt, gmsgid);
+  warned = warning_at (exploc, opt, "%s", gmsgid);
   ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
   if (*ofwhat && warned)
     inform (exploc, "(near initialization for %qs)", ofwhat);
@@ -12267,7 +12267,7 @@
   if ((invalid_op_diag
        = targetm.invalid_binary_op (code, type0, type1)))
     {
-      error_at (location, invalid_op_diag);
+      error_at (location, "%s", invalid_op_diag);
       return error_mark_node;
     }

--- gcc-13.2.0/gcc/c/c-convert.cc	2023-07-27 17:13:04.000000000 +0900
+++ gcc-13.2.0-fix/gcc/c/c-convert.cc	2023-10-08 00:31:08.509315115 +0900
@@ -81,7 +81,7 @@
   if ((invalid_conv_diag
        = targetm.invalid_conversion (TREE_TYPE (expr), type)))
     {
-      error (invalid_conv_diag);
+      error ("%s", invalid_conv_diag);
       return error_mark_node;
     }

--- gcc-13.2.0/gcc/c-family/c-common.cc	2023-07-27 17:13:04.000000000 +0900
+++ gcc-13.2.0-fix/gcc/c-family/c-common.cc	2023-10-08 00:37:20.989309593 +0900
@@ -6608,11 +6608,11 @@
       message = NULL;
     }
   else
-    error_at (richloc, gmsgid);
+    error_at (richloc, "%s", gmsgid);

   if (message)
     {
-      error_at (richloc, message);
+      error_at (richloc, "%s", message);
       free (message);
     }
 #undef catenate_messages
--- gcc-13.2.0/gcc/fold-const.cc	2023-07-27 17:13:04.000000000 +0900
+++ gcc-13.2.0-fix/gcc/fold-const.cc	2023-10-08 00:45:57.205968608 +0900
@@ -310,7 +310,7 @@
 	}
     }
   else if (issue_strict_overflow_warning (wc))
-    warning (OPT_Wstrict_overflow, gmsgid);
+    warning (OPT_Wstrict_overflow, "%s", gmsgid);
 }


 /* Return true if the built-in mathematical function specified by CODE
--- gcc-13.2.0/gcc/gimple-range-gori.cc	2023-07-27 17:13:04.000000000 +0900
+++ gcc-13.2.0-fix/gcc/gimple-range-gori.cc	2023-10-08 01:01:59.515954341 +0900
@@ -315,7 +315,7 @@
       bitmap chain = (has_def_chain (name) ? get_def_chain (name) : NULL);
       if (chain && !bitmap_empty_p (chain))
 	{
-	  fprintf (f, prefix);
+	  fprintf (f, "%s", prefix);
 	  print_generic_expr (f, name, TDF_SLIM);
 	  fprintf (f, " : ");

--- gcc-13.2.0/gcc/ipa-devirt.cc	2023-07-27 17:13:04.000000000 +0900
+++ gcc-13.2.0-fix/gcc/ipa-devirt.cc	2023-10-08 01:40:48.019253159 +0900
@@ -962,7 +962,7 @@
     }
   else
     return;
-  inform (DECL_SOURCE_LOCATION (decl2), reason);
+  inform (DECL_SOURCE_LOCATION (decl2), "%s", reason);

   if (warned)
     *warned = true;
--- gcc-13.2.0/gcc/tree-ssa-sccvn.cc	2023-07-27 17:13:07.000000000 +0900
+++ gcc-13.2.0-fix/gcc/tree-ssa-sccvn.cc	2023-10-08 02:05:11.865898128 +0900
@@ -277,7 +277,7 @@
       if (vro->op0 || vro->opcode == CALL_EXPR)
 	{
 	  if (!vro->op0)
-	    fprintf (outfile, internal_fn_name ((internal_fn)vro->clique));
+	    fprintf (outfile, "%s", internal_fn_name ((internal_fn)vro->clique));
 	  else
 	    print_generic_expr (outfile, vro->op0);
 	  if (vro->op1)
--- gcc-13.2.0/gcc/analyzer/program-state.cc	2023-07-27 17:13:04.000000000 +0900
+++ gcc-13.2.0-fix/gcc/analyzer/program-state.cc	2023-10-08 02:33:51.249205973 +0900
@@ -1419,7 +1419,7 @@
 log_set_of_svalues (logger *logger, const char *name,
 		    const svalue_set &set)
 {
-  logger->log (name);
+  logger->log ("%s", name);
   logger->inc_indent ();
   auto_vec<const svalue *> sval_vecs (set.elements ());
   for (svalue_set::iterator iter = set.begin ();
--- gcc-13.2.0/gcc/diagnostic.cc	2023-07-27 17:13:04.000000000 +0900
+++ gcc-13.2.0-fix/gcc/diagnostic.cc	2023-10-08 02:56:59.199185400 +0900
@@ -2232,7 +2232,7 @@
   if (global_dc->printer == NULL)
     {
       /* Print the error message.  */
-      fnotice (stderr, diagnostic_kind_text[DK_ICE]);
+      fnotice (stderr, "%s", diagnostic_kind_text[DK_ICE]);
       fnotice (stderr, "in %s, at %s:%d", function, trim_filename (file), line);
       fputc ('\n', stderr);

--- gcc-13.2.0/gcc/collect2.cc	2023-07-27 17:13:04.000000000 +0900
+++ gcc-13.2.0-fix/gcc/collect2.cc	2023-10-08 03:13:18.379170885 +0900
@@ -2394,7 +2394,7 @@
 	  fatal_error (input_location, "%s: %m", _(errmsg));
 	}
       else
-	fatal_error (input_location, errmsg);
+	fatal_error (input_location, "%s", errmsg);
     }

   int_handler  = (void (*) (int)) signal (SIGINT,  SIG_IGN);
--- gcc-13.2.0/gcc/collect-utils.cc	2023-07-27 17:13:04.000000000 +0900
+++ gcc-13.2.0-fix/gcc/collect-utils.cc	2023-10-08 03:30:11.889155862 +0900
@@ -234,7 +234,7 @@
 	  fatal_error (input_location, "%s: %m", _(errmsg));
 	}
       else
-	fatal_error (input_location, errmsg);
+	fatal_error (input_location, "%s", errmsg);
     }

   free (response_arg);
--- gcc-13.2.0/gcc/lto-wrapper.cc	2023-07-27 17:13:04.000000000 +0900
+++ gcc-13.2.0-fix/gcc/lto-wrapper.cc	2023-10-08 03:52:54.985802324 +0900
@@ -1148,7 +1148,11 @@

   lseek (fd, file_offset + offset, SEEK_SET);
   data = (char *)xmalloc (length);
-  read (fd, data, length);
+  ssize_t br = read (fd, data, length);
+  if (br == -1 || br != length) {
+    printf("開けない。");
+    return false;
+  }
   fopts = data;
   do
     {
@@ -1366,7 +1370,7 @@
   if (print_url)
     pp_end_url (&pp);
   pp_string (&pp, " for more information");
-  inform (UNKNOWN_LOCATION, pp_formatted_text (&pp));
+  inform (UNKNOWN_LOCATION, "%s", pp_formatted_text (&pp));
 }

 /* Test that a make command is present and working, return true if so.  */
@@ -1968,7 +1972,7 @@
 	  jobserver_info jinfo;
 	  if (jobserver_requested && !jinfo.is_active)
 	    {
-	      warning (0, jinfo.error_msg.c_str ());
+	      warning (0, "%s", jinfo.error_msg.c_str ());
 	      print_lto_docs_link ();
 	    }
 	  else if (parallel == 0)
--- gcc-13.2.0/gcc/genhooks.cc	2023-07-27 17:13:04.000000000 +0900
+++ gcc-13.2.0-fix/gcc/genhooks.cc	2023-10-08 15:21:02.301857011 +0900
@@ -97,7 +97,7 @@
 emit_documentation (const char *in_fname)
 {
   int i, j;
-  char buf[1000];
+  char buf[10000];
   htab_t start_hooks = htab_create (99, s_hook_hash, s_hook_eq_p, (htab_del) 0);
   FILE *f;

@@ -108,24 +108,30 @@
       perror ("");
       fatal ("Couldn't open input file");
     }
-  while (fscanf (f, "%*[^@]"), buf[0] = '\0',
-	 fscanf (f, "@%5[^ \n]", buf) != EOF)
-    {
-      void **p;
-      struct s_hook *shp;
+  char line[10000000];
+  while (fgets(line, sizeof(line), f)) {
+    char *token = strtok(line, " \n");

-      if (strcmp (buf, "hook") != 0)
-	continue;
-      buf[0] = '\0';
-      fscanf (f, "%999s", buf);
-      shp = XNEW (struct s_hook);
-      shp->name = upstrdup (buf);
-      shp->pos = -1;
-      p = htab_find_slot (start_hooks, shp, INSERT);
-      if (*p != HTAB_EMPTY_ENTRY)
-	fatal ("Duplicate placement for hook %s\n", shp->name);
-      *(struct s_hook **) p = shp;
+    if (!token) continue;
+    if (token[0] != '@') continue;
+    if (strcmp(token, "@hook") != 0) continue;
+    token = strtok(NULL, " \n");
+
+    if (!token) {
+      fatal("Unexpected EOF after @hook\n");
     }
+
+    void **p;
+    struct s_hook *shp;
+
+    shp = XNEW (struct s_hook);
+    shp->name = upstrdup (token);
+    shp->pos = -1;
+    p = htab_find_slot (start_hooks, shp, INSERT);
+    if (*p != HTAB_EMPTY_ENTRY)
+      fatal ("Duplicate placement for hook %s\n", shp->name);
+    *(struct s_hook **) p = shp;
+  }
   fclose (f);
   /* For each hook in hook_array, if it is a start hook, store its position.  */
   for (i = 0; i < (int) (ARRAY_SIZE (hook_array)); i++)
@@ -170,13 +176,17 @@
 	  continue;
 	}
       buf[0] = '\0';
-      fscanf (f, "%5[^ \n]", buf);
+      if (fscanf (f, "%5[^ \n]", buf) != 1) {
+        fatal("fscanf err 2\n");
+      }
       if (strcmp (buf, "hook") != 0)
 	{
 	  printf ("@%s", buf);
 	  continue;
 	}
-      fscanf (f, "%999s", buf);
+      if (fscanf (f, "%9999999s", buf) != 1) {
+        fatal("fscanf err 3\n");
+      }
       sh.name = name = upstrdup (buf);
       shp = (struct s_hook *) htab_find (start_hooks, &sh);
       if (!shp || shp->pos < 0)
--- gcc-13.2.0/gcc/lto/lto-common.cc	2023-07-27 17:13:04.000000000 +0900
+++ gcc-13.2.0-fix/gcc/lto/lto-common.cc	2023-10-08 04:43:48.319090396 +0900
@@ -2078,9 +2078,16 @@

   name_len = strlen (file->filename);
   obj_name = XNEWVEC (char, name_len + 1);
-  fscanf (resolution, " ");   /* Read white space.  */
+  if (fscanf (resolution, " ") == EOF) {   /* Read white space.  */
+    fprintf(stderr, "Failed to read whitespace.\n");
+    return;
+  }

-  fread (obj_name, sizeof (char), name_len, resolution);
+  size_t ir = fread(obj_name, sizeof (char), name_len, resolution);
+  if (ir != name_len) {
+    fprintf(stderr, "Failed to read object name.\n");
+    return;
+  }
   obj_name[name_len] = '\0';
   if (filename_cmp (obj_name, file->filename) != 0)
     internal_error ("unexpected file name %s in linker resolution file. "
@@ -2100,7 +2107,10 @@

   free (obj_name);

-  fscanf (resolution, "%u", &num_symbols);
+  if (fscanf(resolution, "%u", &num_symbols) != 1) {
+    fprintf(stderr, "Failed to read number of symbols.\n");
+    return;
+  }

   for (i = 0; i < num_symbols; i++)
     {
--- gcc-13.2.0/libgcc/libgcov-util.c	2023-07-27 17:13:07.000000000 +0900
+++ gcc-13.2.0-fix/libgcc/libgcov-util.c	2023-10-08 04:49:44.339085119 +0900
@@ -452,10 +452,13 @@
 #ifdef HAVE_FTW_H
   ftw (".", ftw_read_file, 50);
 #endif
-  chdir (pwd);
+  if (chdir(pwd) == -1) {
+    printf("chdir err\n");
+    return NULL;
+  }
   free (pwd);

-  return gcov_info_head;;
+  return gcov_info_head;
 }

 /* This part of the code is to merge profile counters. These
--- gcc-13.2.0/gcc/gcc.cc	2023-07-27 17:13:04.000000000 +0900
+++ gcc-13.2.0-fix/gcc/gcc.cc	2023-10-08 04:57:04.852411922 +0900
@@ -7750,13 +7750,17 @@
   int fd = open (*out_file, O_RDWR | O_APPEND);
   if (fd < 0)
     return;
-  write (fd, "\n//", 3);
+  ssize_t w1 = write(fd, "\n//", 3);
+  if (w1 == -1) return;
   for (i = 0; i < nargs; i++)
     {
-      write (fd, " ", 1);
-      write (fd, new_argv[i], strlen (new_argv[i]));
+      ssize_t w2 = write(fd, " ", 1);
+      if (w2 == -1) return;
+      ssize_t w3 = write(fd, new_argv[i], strlen (new_argv[i]));
+      if (w3 == -1) return;
     }
-  write (fd, "\n\n", 2);
+  ssize_t w4 = write(fd, "\n\n", 2);
+  if (w4 == -1) return;
   close (fd);
   new_argv[nargs] = "-E";
   new_argv[nargs + 1] = NULL;
@@ -10520,7 +10524,10 @@
   fd = open ("/dev/urandom", O_RDONLY);
   if (fd >= 0)
     {
-      read (fd, &ret, sizeof (HOST_WIDE_INT));
+      ssize_t br = read(fd, &ret, sizeof (HOST_WIDE_INT));
+      if (br == -1) {
+        return -1;
+      }
       close (fd);
       if (ret)
         return ret;
