File: main.go

package info (click to toggle)
golang-golang-x-vuln 1.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,400 kB
  • sloc: sh: 161; asm: 40; makefile: 7
file content (100 lines) | stat: -rw-r--r-- 1,701 bytes parent folder | 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package main

import (
	"fmt"
	"os"

	"golang.org/x/text/language"
)

func main() {
	args := os.Args[1:]

	// Calls foo which directly calls language.Parse.
	A()

	// Also calls foo which directly calls language.Parse.
	B()

	// Calls language.Parse directly.
	//
	// This will be displayed by govulncheck, since it is the shortest path.
	C()

	// Calls foobar which eventually calls language.MustParse (different
	// symbol, same report)
	D()

	// Calls moreFoo which directly calls language.Parse.
	E(args)

	// Calls stillMoreFoo which directly calls language.Parse.
	F(args)
}

func A() {
	foo(os.Args[1:])
}

func B() {
	foo(os.Args[1:])
}

func C() {
	_, _ = language.Parse("")
}

func D() {
	foobar()
}

func E(args []string) {
	moreFoo(args)
}

func F(args []string) {
	stillMoreFoo(args)
}

func foo(args []string) {
	for _, arg := range args {
		tag, err := language.Parse(arg)
		if err != nil {
			fmt.Printf("%s: error: %v\n", arg, err)
		} else if tag == language.Und {
			fmt.Printf("%s: undefined\n", arg)
		} else {
			fmt.Printf("%s: tag %s\n", arg, tag)
		}
	}
}

func moreFoo(args []string) {
	for _, arg := range args {
		tag, err := language.Parse(arg)
		if err != nil {
			fmt.Printf("%s: error: %v\n", arg, err)
		} else if tag == language.Und {
			fmt.Printf("%s: undefined\n", arg)
		} else {
			fmt.Printf("%s: tag %s\n", arg, tag)
		}
	}
}

func stillMoreFoo(args []string) {
	for _, arg := range args {
		tag, err := language.Parse(arg)
		if err != nil {
			fmt.Printf("%s: error: %v\n", arg, err)
		} else if tag == language.Und {
			fmt.Printf("%s: undefined\n", arg)
		} else {
			fmt.Printf("%s: tag %s\n", arg, tag)
		}
	}
}

func foobar() {
	language.MustParse("")
}