changeset 13670:345ef0469dd6

8220072: GCC 8.3 reports errors in java.base Reviewed-by: rriggs
author dchuyko
date Wed, 22 May 2019 21:33:58 +0300
parents d44a3f4b841f
children 08c46bf8a620
files src/solaris/native/java/io/canonicalize_md.c
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/java/io/canonicalize_md.c	Wed Sep 04 05:41:50 2019 +0100
+++ b/src/solaris/native/java/io/canonicalize_md.c	Wed May 22 21:33:58 2019 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -211,11 +211,10 @@
         char *p, *end, *r = NULL;
         char path[PATH_MAX + 1];
 
-        strncpy(path, original, sizeof(path));
-        if (path[PATH_MAX] != '\0') {
-            errno = ENAMETOOLONG;
-            return -1;
-        }
+        // strlen(original) <= PATH_MAX, see above
+        strncpy(path, original, PATH_MAX);
+        // append null for == case
+        path[PATH_MAX] = '\0';
         end = path + strlen(path);
 
         for (p = end; p > path;) {