win32_fstat has a potential buffer overrun problem
Jan Dubois [Sun, 7 Mar 2004 17:04:35 +0000 (09:04 -0800)]
Message-ID: <8lgn409p4k2kpde8d428d7a4r7fsgjc8b4@4ax.com>

p4raw-id: //depot/perl@22466

win32/win32.c

index 19662af..b36a7b7 100644 (file)
@@ -1182,6 +1182,10 @@ win32_stat(const char *path, Stat_t *sbuf)
        /* FindFirstFile() and stat() are buggy with a trailing
         * backslash, so change it to a forward slash :-( */
        case '\\':
+           if (l >= sizeof(buffer)) {
+               errno = ENAMETOOLONG;
+               return -1;
+           }
            strncpy(buffer, path, l-1);
            buffer[l - 1] = '/';
            buffer[l] = '\0';