OSDN Git Service

Fix a mkstemp() file name generator defect.
authorKeith Marshall <keith@users.osdn.me>
Fri, 11 Jan 2019 20:03:49 +0000 (20:03 +0000)
committerKeith Marshall <keith@users.osdn.me>
Fri, 11 Jan 2019 20:03:49 +0000 (20:03 +0000)
mingwrt/ChangeLog
mingwrt/mingwex/cryptnam.c

index 4261278..31d9509 100644 (file)
@@ -1,5 +1,13 @@
 2019-01-11  Keith Marshall  <keith@users.osdn.me>
 
 2019-01-11  Keith Marshall  <keith@users.osdn.me>
 
+       Fix a mkstemp() file name generator defect.
+
+       * mingwex/cryptnam.c (crypto_random_filename_char): Revert 2018-09-06
+       change; argument type must be unsigned char *, to avoid math errors.
+       (__mingw_crypto_tmpname): Use explicit casts to resolve type conflicts.
+
+2019-01-11  Keith Marshall  <keith@users.osdn.me>
+
        Fix a <stdio.h> typedef omission.
 
        * include/stdio.h: Adjust comment formatting.
        Fix a <stdio.h> typedef omission.
 
        * include/stdio.h: Adjust comment formatting.
index 4b6eac4..7758518 100644 (file)
@@ -10,7 +10,7 @@
  * $Id$
  *
  * Written by Keith Marshall  <keithmarshall@users.sourceforge.net>
  * $Id$
  *
  * Written by Keith Marshall  <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2013, 2014, 2018, MinGW.org Project.
+ * Copyright (C) 2013, 2014, 2018, 2019, MinGW.org Project.
  *
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  *
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -94,7 +94,8 @@ CRYPTO_INLINE void *crypto_randomize( void *buf, size_t buflen )
   return NULL;
 }
 
   return NULL;
 }
 
-CRYPTO_INLINE char *crypto_random_filename_char( char *caret )
+CRYPTO_INLINE
+unsigned char *crypto_random_filename_char( unsigned char *caret )
 {
   /* Helper to generate a random sequence of characters, suitable for
    * use in file names; although there are other valid possibilities, we
 {
   /* Helper to generate a random sequence of characters, suitable for
    * use in file names; although there are other valid possibilities, we
@@ -155,12 +156,12 @@ char *__mingw_crypto_tmpname( char *template )
    * We begin by locating the position, within the given template,
    * where the string of six replaceable 'XXXXXX's should begin.
    */
    * We begin by locating the position, within the given template,
    * where the string of six replaceable 'XXXXXX's should begin.
    */
-  char *tail = template + strlen( template ) - 6;
+  unsigned char *tail = (unsigned char *)(template) + strlen( template ) - 6;
 
   /* Provided this appears sane -- i.e. it at least doesn't place the
    * six character "tail" before the start of the template itself...
    */
 
   /* Provided this appears sane -- i.e. it at least doesn't place the
    * six character "tail" before the start of the template itself...
    */
-  if( tail >= template )
+  if( (char *)(tail) >= template )
   {
     /* ...then, walk over each of the six bytes of the "tail", until
      * we reach the NUL terminator...
   {
     /* ...then, walk over each of the six bytes of the "tail", until
      * we reach the NUL terminator...