~ubuntu-branches/ubuntu/saucy/nss-pam-ldapd/saucy

« back to all changes in this revision

Viewing changes to nslcd/service.c

  • Committer: Package Import Robot
  • Author(s): Arthur de Jong
  • Date: 2012-05-20 23:00:00 UTC
  • mfrom: (16.1.4)
  • Revision ID: package-import@ubuntu.com-20120520230000-a8d8wbxsii49jt1j
Tags: 0.8.9-1
* new upstream release:
  - allow the pam_authz_search option to be specified multiple times
  - implement extra range checking of all numeric values
  - make documentation up-to-date
  - compatibility improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
   Copyright (C) 1997-2005 Luke Howard
7
7
   Copyright (C) 2006 West Consulting
8
 
   Copyright (C) 2006, 2007, 2009, 2010, 2011 Arthur de Jong
 
8
   Copyright (C) 2006, 2007, 2009, 2010, 2011, 2012 Arthur de Jong
9
9
 
10
10
   This library is free software; you can redistribute it and/or
11
11
   modify it under the terms of the GNU Lesser General Public
28
28
#include <stdio.h>
29
29
#include <stdlib.h>
30
30
#include <string.h>
 
31
#include <stdint.h>
31
32
 
32
33
#include "common.h"
33
34
#include "log.h"
136
137
  const char **ports;
137
138
  const char **protocols;
138
139
  char *tmp;
139
 
  int port;
 
140
  long port;
140
141
  int i;
141
142
  /* get the most canonical name */
142
143
  name=myldap_get_rdn_value(entry,attmap_service_cn);
173
174
                        myldap_get_dn(entry),attmap_service_ipServicePort);
174
175
  }
175
176
  errno=0;
176
 
  port=(int)strtol(ports[0],&tmp,10);
 
177
  port=strtol(ports[0],&tmp,10);
177
178
  if ((*(ports[0])=='\0')||(*tmp!='\0'))
178
179
  {
179
180
    log_log(LOG_WARNING,"%s: %s: non-numeric value",
180
181
                        myldap_get_dn(entry),attmap_service_ipServicePort);
181
182
    return 0;
182
183
  }
183
 
  else if (errno!=0)
 
184
  else if ((errno!=0)||(port<=0)||(port>UINT16_MAX))
184
185
  {
185
 
    log_log(LOG_WARNING,"%s: %s: too large",
 
186
    log_log(LOG_WARNING,"%s: %s: out of range",
186
187
                        myldap_get_dn(entry),attmap_service_ipServicePort);
187
188
    return 0;
188
189
  }
201
202
      WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
202
203
      WRITE_STRING(fp,name);
203
204
      WRITE_STRINGLIST_EXCEPT(fp,aliases,name);
 
205
      /* port number is actually a 16-bit value but we write 32 bits anyway */
204
206
      WRITE_INT32(fp,port);
205
207
      WRITE_STRING(fp,protocols[i]);
206
208
    }