~ubuntu-branches/ubuntu/karmic/pdnsd/karmic

« back to all changes in this revision

Viewing changes to src/status.c

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Habouzit
  • Date: 2008-10-05 09:54:52 UTC
  • mfrom: (4.1.4 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081005095452-wc58cmdofvyipcv3
Tags: 1.2.6-par-10
* Add patches/0005-fix-for-CVE-2008-4194.patch for CVE-2008-4194.
  (Closes: #500910).
* Document where the two default configuration are in README.Debian
  (Closes: #499984).
* Update turkish translation thanks to Mert Dirik (Closes: #490047).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* status.c - Allow control of a running server using a socket
2
2
 
3
3
   Copyright (C) 2000, 2001 Thomas Moestl
4
 
   Copyright (C) 2002, 2003, 2004, 2005 Paul A. Rombouts
5
 
 
6
 
This file is part of the pdnsd package.
7
 
 
8
 
pdnsd is free software; you can redistribute it and/or modify
9
 
it under the terms of the GNU General Public License as published by
10
 
the Free Software Foundation; either version 2, or (at your option)
11
 
any later version.
12
 
 
13
 
pdnsd is distributed in the hope that it will be useful,
14
 
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
GNU General Public License for more details.
17
 
 
18
 
You should have received a copy of the GNU General Public License
19
 
along with pdsnd; see the file COPYING.  If not, write to
20
 
the Free Software Foundation, 59 Temple Place - Suite 330,
21
 
Boston, MA 02111-1307, USA.  */
 
4
   Copyright (C) 2002, 2003, 2004, 2005, 2007 Paul A. Rombouts
 
5
 
 
6
  This file is part of the pdnsd package.
 
7
 
 
8
  pdnsd is free software; you can redistribute it and/or modify
 
9
  it under the terms of the GNU General Public License as published by
 
10
  the Free Software Foundation; either version 3 of the License, or
 
11
  (at your option) any later version.
 
12
 
 
13
  pdnsd is distributed in the hope that it will be useful,
 
14
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
  GNU General Public License for more details.
 
17
 
 
18
  You should have received a copy of the GNU General Public License
 
19
  along with pdnsd; see the file COPYING. If not, see
 
20
  <http://www.gnu.org/licenses/>.
 
21
*/
22
22
 
23
23
#include <config.h>
24
24
#include <stdio.h>
126
126
{
127
127
        uint16_t count;
128
128
        char *buf;
129
 
        int nread;
 
129
        unsigned int nread;
130
130
 
131
131
        if(!read_short(fh,&count)) return 0;
132
132
        if(count==(uint16_t)(~0)) {*res=NULL; return -1;}
133
133
        if(!(buf=malloc(count+1))) return 0;
134
134
        nread=0;
135
135
        while(nread<count) {
136
 
                int m=read(fh,buf+nread,count-nread);
 
136
                ssize_t m=read(fh,buf+nread,count-nread);
137
137
                if(m<=0) {free(buf); return 0;}
138
138
                nread+=m;
139
139
        }
152
152
static int read_domain(int fh, char *buf, int buflen)
153
153
{
154
154
        uint16_t count;
155
 
        int nread;
 
155
        unsigned int nread;
156
156
 
157
157
        /* PDNSD_ASSERT(buflen>0, "bad read_domain call"); */
158
158
        if(!read_short(fh,&count)) return 0;
160
160
        if(count >=buflen) return 0;
161
161
        nread=0;
162
162
        while(nread<count) {
163
 
                int m=read(fh,buf+nread,count-nread);
 
163
                ssize_t m=read(fh,buf+nread,count-nread);
164
164
                if(m<=0) return 0;
165
165
                nread+=m;
166
166
        }
167
167
        buf[count]=0;
168
 
        /* if(count==0 || buf[count-1]!='.') {
 
168
#if 0
 
169
        if(count==0 || buf[count-1]!='.') {
169
170
                if(count+1>=buflen) return 0;
170
171
                buf[count]='.'; buf[count+1]=0;
171
 
        } */
 
172
        }
 
173
#endif
172
174
        return 1;
173
175
}
174
176
 
408
410
                                    break;
409
411
                            case CTL_ADD: {
410
412
                                    uint32_t ttl;
411
 
                                    int sz;
412
 
                                    uint16_t tp,flags;
 
413
                                    unsigned sz;
 
414
                                    uint16_t tp,flags,nadr=0;
413
415
                                    unsigned char name[256],buf[256],dbuf[260];
 
416
                                    size_t adrbufsz=0;
 
417
                                    unsigned char *adrbuf=NULL;
414
418
 
415
419
                                    DEBUG_MSG("Received ADD command.\n");
416
420
                                    if (!read_short(rs,&tp))
428
432
 
429
433
                                    switch (tp) {
430
434
                                    case T_A:
431
 
                                            if (read(rs,dbuf,sizeof(struct in_addr))!=sizeof(struct in_addr))
432
 
                                                    goto bad_arg;
433
435
                                            sz=sizeof(struct in_addr);
434
 
                                            break;
435
 
#ifdef ENABLE_IPV6
 
436
#if ALLOW_LOCAL_AAAA
 
437
                                            goto read_adress_list;
436
438
                                    case T_AAAA:
437
 
                                            if (read(rs,dbuf,sizeof(struct in6_addr))!=sizeof(struct in6_addr))
438
 
                                                    goto bad_arg;
439
439
                                            sz=sizeof(struct in6_addr);
 
440
                                    read_adress_list:
 
441
#endif
 
442
                                            if (!read_short(rs,&nadr))
 
443
                                                    goto incomplete_command;
 
444
                                            if (!nadr)
 
445
                                                    goto bad_arg;
 
446
                                            adrbufsz= nadr * (size_t)sz;
 
447
                                            adrbuf= malloc(adrbufsz);
 
448
                                            if(!adrbuf)
 
449
                                                    goto out_of_memory;
 
450
                                            {
 
451
                                                    size_t nread=0;
 
452
                                                    while(nread<adrbufsz) {
 
453
                                                            ssize_t m=read(rs,adrbuf+nread,adrbufsz-nread);
 
454
                                                            if(m<=0) {free(adrbuf); goto bad_arg;}
 
455
                                                            nread += m;
 
456
                                                    }
 
457
                                            }
440
458
                                            break;
441
 
#endif
442
459
                                    case T_CNAME:
443
460
                                    case T_PTR:
444
461
                                            if (read_domain(rs, charp buf, sizeof(buf))<=0)
462
479
                                    {
463
480
                                            dns_cent_t cent;
464
481
 
465
 
                                            if (!init_cent(&cent, name, 0, 0, flags  DBG1))
 
482
                                            if (!init_cent(&cent, name, 0, 0, flags  DBG1)) {
 
483
                                                    free(adrbuf);
466
484
                                                    goto out_of_memory;
467
 
                                            if (!add_cent_rr(&cent,tp,ttl,0,CF_LOCAL,sz,dbuf  DBG1)) {
 
485
                                            }
 
486
                                            if(adrbuf) {
 
487
                                                    unsigned char *adrp; int i;
 
488
                                                    for(adrp=adrbuf,i=0; i<nadr; adrp += sz,++i) {
 
489
                                                            if (!add_cent_rr(&cent,tp,ttl,0,CF_LOCAL,sz,adrp  DBG1)) {
 
490
                                                                    free_cent(&cent  DBG1);
 
491
                                                                    free(adrbuf);
 
492
                                                                    goto out_of_memory;
 
493
                                                            }
 
494
                                                    }
 
495
                                                    free(adrbuf);
 
496
                                            }
 
497
                                            else if (!add_cent_rr(&cent,tp,ttl,0,CF_LOCAL,sz,dbuf  DBG1)) {
468
498
                                                    free_cent(&cent  DBG1);
469
499
                                                    goto out_of_memory;
470
500
                                            }