Package: heimdal / 7.1.0+dfsg-13+deb9u3

042_hurd_path_max Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
--- a/lib/sl/slc-gram.y
+++ b/lib/sl/slc-gram.y
@@ -670,8 +670,8 @@
     cprint(0, "\n");
 }
 
-char cname[PATH_MAX];
-char hname[PATH_MAX];
+char *cname = NULL;
+char *hname = NULL;
 
 static void
 gen(struct assignment *as)
@@ -721,6 +721,8 @@
 
     int optidx = 0;
 
+    size_t cname_len = 0;
+
     setprogname(argv[0]);
     if(getarg(args, num_args, argc, argv, &optidx))
 	usage(1);
@@ -739,16 +741,22 @@
     if(yyin == NULL)
 	err(1, "%s", filename);
     p = strrchr(filename, '/');
-    if(p)
-	strlcpy(cname, p + 1, sizeof(cname));
-    else
-	strlcpy(cname, filename, sizeof(cname));
+    if(p) {
+	cname_len = strlen(p + 1) + 2 + 1;
+	cname = malloc(cname_len);
+	strlcpy(cname, p + 1, cname_len);
+    } else {
+	cname_len = strlen(filename) + 2 + 1;
+	cname = malloc(cname_len);
+	strlcpy(cname, filename, cname_len);
+    }
     p = strrchr(cname, '.');
     if(p)
 	*p = '\0';
-    strlcpy(hname, cname, sizeof(hname));
-    strlcat(cname, ".c", sizeof(cname));
-    strlcat(hname, ".h", sizeof(hname));
+    hname = malloc(cname_len);
+    strlcpy(hname, cname, cname_len);
+    strlcat(cname, ".c", cname_len);
+    strlcat(hname, ".h", cname_len);
     yyparse();
     if(error_flag)
 	exit(1);
@@ -764,5 +772,7 @@
 	fclose(hfile);
     }
     fclose(yyin);
+    free(cname);
+    free(hname);
     return 0;
 }