~damg/ubuntu/quantal/asterisk/LP1097687

« back to all changes in this revision

Viewing changes to main/astfd.c

  • Committer: Bazaar Package Importer
  • Author(s): Jean-Michel Dault
  • Date: 2010-02-16 14:08:54 UTC
  • mfrom: (1.2.5 upstream) (8.3.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100216140854-rb2godspb9lduazl
Tags: 1:1.6.2.2-1ubuntu1
* Merge from Debian: security update
  * Changes:
  - debian/control: Change Maintainer
  - debian/control: Removed Uploaders field.
  - debian/control: Removed Debian Vcs-Svn entry and replaced with
      ubuntu-voip Vcs-Bzr, to reflect divergence in packages.
  - debian/asterisk.init : chown /dev/dahdi
  - debian/backports/hardy : add file
  - debian/backports/asterisk.init.hardy : add file

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
#ifdef DEBUG_FD_LEAKS
29
29
 
30
 
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 211278 $")
 
30
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 228340 $")
31
31
 
32
32
#include <stdio.h>
33
33
#include <string.h>
130
130
#undef socket
131
131
int __ast_fdleak_socket(int domain, int type, int protocol, const char *file, int line, const char *func)
132
132
{
133
 
        char sdomain[20], stype[20], *sproto;
 
133
        char sdomain[20], stype[20], *sproto = NULL;
134
134
        struct protoent *pe;
135
135
        int res = socket(domain, type, protocol);
136
136
        if (res < 0 || res > 1023) {
137
137
                return res;
138
138
        }
139
139
 
140
 
        pe = getprotobynumber(protocol);
141
 
        sproto = pe->p_name;
 
140
        if ((pe = getprotobynumber(protocol))) {
 
141
                sproto = pe->p_name;
 
142
        }
142
143
 
143
144
        if (domain == PF_UNIX) {
144
145
                ast_copy_string(sdomain, "PF_UNIX", sizeof(sdomain));
162
163
                snprintf(stype, sizeof(stype), "%d", type);
163
164
        }
164
165
 
165
 
        STORE_COMMON(res, "socket", "%s,%s,\"%s\"", sdomain, stype, sproto);
 
166
        if (sproto) {
 
167
                STORE_COMMON(res, "socket", "%s,%s,\"%s\"", sdomain, stype, sproto);
 
168
        } else {
 
169
                STORE_COMMON(res, "socket", "%s,%s,\"%d\"", sdomain, stype, protocol);
 
170
        }
166
171
        return res;
167
172
}
168
173