aboutsummaryrefslogtreecommitdiffstats
path: root/dns/dhid/files/patch-ac
blob: 5994ae7827f17ca0b7491c103a8abfc7a91cfc32 (plain) (blame)
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
--- main.c.orig Thu Nov 20 22:11:59 2003
+++ main.c  Sat Feb 19 21:22:50 2005
@@ -74,7 +74,7 @@
                         unsigned char linecmd[512];
                         struct in_addr sa;
                         sa.s_addr=cp->laddr;
-                        sprintf(linecmd,"%s %d %s %s",cp->off_cmd,cp->id,
+                        snprintf(linecmd,sizeof(linecmd),"%s %d %s %s",cp->off_cmd,cp->id,
                         inet_ntoa((struct in_addr)sa)
                         ,cp->off_cmdp);
                         cmd_fork(linecmd);
@@ -106,7 +106,7 @@
                         unsigned char linecmd[512];
                         struct in_addr sa;
                         sa.s_addr=cp->laddr;
-                        sprintf(linecmd,"%s %d %s %s",cp->off_cmd,cp->id,
+                        snprintf(linecmd,sizeof(linecmd),"%s %d %s %s",cp->off_cmd,cp->id,
                         inet_ntoa((struct in_addr)sa)
                         ,cp->off_cmdp);
                         cmd_fork(linecmd);
@@ -189,7 +189,7 @@
        unsigned char linecmd[512];
        struct in_addr sa;
        sa.s_addr=cp->laddr;
-       sprintf(linecmd,"%s %d %s %s",cp->on_cmd,cp->id,
+       snprintf(linecmd,sizeof(linecmd),"%s %d %s %s",cp->on_cmd,cp->id,
        inet_ntoa((struct in_addr)sa)
        ,cp->on_cmdp);
        cmd_fork(linecmd);
@@ -223,8 +223,8 @@
            return;
        cp->cserver=sp;
        cp->stage=AUTH_STAGE;
-       if(cp->atype==APASS) strcpy(m.pass,cp->pass);
-       else memset(m.pass,0,16);
+       if(cp->atype==APASS) strlcpy(m.pass,cp->pass,sizeof(m.pass));
+       else memset(m.pass,0,sizeof(m.pass));
        m.hdr.opcode=AUTH_REQ;
        m.hdr.hostid=cp->id;
        m.refresh=cp->refresh;
@@ -289,25 +289,19 @@
    int c;
    extern char *optarg;
 
-   strcpy(conf_file,DHID_CONF);
-   strcpy(pid_file,DHID_PID);
+   strlcpy(conf_file,DHID_CONF,sizeof(conf_file));
+   strlcpy(pid_file,DHID_PID,sizeof(pid_file));
 
    while((c=getopt(argc,argv,"hf:p:P:"))!=EOF)
    switch(c) {
    case('p'): rport=atoi(optarg); break;
-   case('P'): strncpy(pid_file,optarg,sizeof(pid_file)); break;
-   case('f'): strncpy(conf_file,optarg,sizeof(conf_file)); break;
+   case('P'): strlcpy(pid_file,optarg,sizeof(pid_file)); break;
+   case('f'): strlcpy(conf_file,optarg,sizeof(conf_file)); break;
    case('h'): usage(argv);
    default: usage(argv);
    }
 
    
-   if(getuid()) {
-       syslog(LOG_ERR,"%s must be executed by root",argv[0]);
-       exit(1);
-   }
-
-
    close(0);
    close(1);
    close(2);
@@ -376,7 +370,7 @@
                    unsigned char linecmd[512];
                    struct in_addr sa;
                    sa.s_addr=cp->laddr;
-                   sprintf(linecmd,"%s %d %s %s",cp->off_cmd,cp->id,
+                   snprintf(linecmd,sizeof(linecmd),"%s %d %s %s",cp->off_cmd,cp->id,
                    inet_ntoa((struct in_addr)sa)
                    ,cp->off_cmdp);
                    cmd_fork(linecmd);