]> git.ipfire.org Git - thirdparty/bash.git/blobdiff - stringlib.c
Bash-4.3 distribution sources and documentation
[thirdparty/bash.git] / stringlib.c
index 0a612ca90a7e739c00eac6336b00cd52f169b0d9..95092993adfa4e3a24e5da64e07aabf6d40794f6 100644 (file)
@@ -133,7 +133,7 @@ substring (string, start, end)
 
   len = end - start;
   result = (char *)xmalloc (len + 1);
-  strncpy (result, string + start, len);
+  memcpy (result, string + start, len);
   result[len] = '\0';
   return (result);
 }
@@ -158,7 +158,7 @@ strsub (string, pat, rep, global)
          if (replen)
            RESIZE_MALLOCED_BUFFER (temp, templen, replen, tempsize, (replen * 2));
 
-         for (r = rep; *r; )
+         for (r = rep; *r; )   /* can rep == "" */
            temp[templen++] = *r++;
 
          i += patlen ? patlen : 1;     /* avoid infinite recursion */