pacparser 1.5.3.dev2__tar.gz → 1.5.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pacparser
3
- Version: 1.5.3.dev2
3
+ Version: 1.5.4
4
4
  Summary: Pacparser package
5
5
  Home-page: https://github.com/manugarg/pacparser
6
6
  Author: Manu Garg
@@ -114,6 +114,8 @@ def just_find_proxy(pacfile, url, host=None):
114
114
  def setmyip(ip_address):
115
115
  """
116
116
  Set my ip address. This is the IP address returned by myIpAddress()
117
+
118
+ Raises ValueError if ip_address is too long to be an IP address.
117
119
  """
118
120
  _pacparser.setmyip(ip_address)
119
121
 
@@ -51,7 +51,10 @@
51
51
  # define UNUSED(x) UNUSED_ ## x
52
52
  #endif
53
53
 
54
- static char my_ip_buf[INET6_ADDRSTRLEN+1];
54
+ // Client IP set via pacparser_setmyip(). Sized for the longest textual IP
55
+ // address (45 characters, an IPv6 address with an embedded IPv4 address) plus
56
+ // the terminating NUL. Not INET6_ADDRSTRLEN, which is larger on Windows.
57
+ static char my_ip_buf[46];
55
58
  static int my_ip_set = 0;
56
59
 
57
60
  // Default error printer function.
@@ -250,15 +253,13 @@ my_ip(JSContext *ctx, JSValueConst UNUSED(this_val), int UNUSED(argc), JSValueCo
250
253
  char ipaddr[INET6_ADDRSTRLEN];
251
254
 
252
255
  if (my_ip_set) // If my (client's) IP address is already set.
253
- strcpy(ipaddr, my_ip_buf);
254
- else {
255
- char name[256];
256
- gethostname(name, sizeof(name));
257
- if (resolve_host(name, ipaddr, 1, AF_INET)) {
258
- strcpy(ipaddr, "127.0.0.1");
259
- }
260
- }
256
+ return JS_NewString(ctx, my_ip_buf);
261
257
 
258
+ char name[256];
259
+ gethostname(name, sizeof(name));
260
+ if (resolve_host(name, ipaddr, 1, AF_INET)) {
261
+ strcpy(ipaddr, "127.0.0.1");
262
+ }
262
263
  return JS_NewString(ctx, ipaddr);
263
264
  }
264
265
 
@@ -270,15 +271,13 @@ my_ip_ex(JSContext *ctx, JSValueConst UNUSED(this_val), int UNUSED(argc), JSValu
270
271
  char ipaddr[INET6_ADDRSTRLEN * MAX_IP_RESULTS + MAX_IP_RESULTS];
271
272
 
272
273
  if (my_ip_set) // If my (client's) IP address is already set.
273
- strcpy(ipaddr, my_ip_buf);
274
- else {
275
- char name[256];
276
- gethostname(name, sizeof(name));
277
- if (resolve_host(name, ipaddr, MAX_IP_RESULTS, AF_UNSPEC)) {
278
- strcpy(ipaddr, "");
279
- }
280
- }
274
+ return JS_NewString(ctx, my_ip_buf);
281
275
 
276
+ char name[256];
277
+ gethostname(name, sizeof(name));
278
+ if (resolve_host(name, ipaddr, MAX_IP_RESULTS, AF_UNSPEC)) {
279
+ strcpy(ipaddr, "");
280
+ }
282
281
  return JS_NewString(ctx, ipaddr);
283
282
  }
284
283
 
@@ -292,8 +291,8 @@ static const char *proxy_result = NULL;
292
291
  int
293
292
  pacparser_setmyip(const char *ip)
294
293
  {
295
- if (strlen(ip) > INET6_ADDRSTRLEN) {
296
- fprintf(stderr, "pacparser_setmyip: IP too long: %s\n", ip);
294
+ if (strlen(ip) >= sizeof(my_ip_buf)) {
295
+ print_error("pacparser_setmyip: IP too long: %s\n", ip);
297
296
  return 0;
298
297
  }
299
298
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pacparser
3
- Version: 1.5.3.dev2
3
+ Version: 1.5.4
4
4
  Summary: Pacparser package
5
5
  Home-page: https://github.com/manugarg/pacparser
6
6
  Author: Manu Garg
@@ -128,7 +128,10 @@ py_pacparser_setmyip(PyObject *self, PyObject *args)
128
128
  const char *ip;
129
129
  if (!PyArg_ParseTuple(args, "s", &ip))
130
130
  return NULL;
131
- pacparser_setmyip(ip);
131
+ if (!pacparser_setmyip(ip)) {
132
+ PyErr_Format(PyExc_ValueError, "invalid IP address: %s", ip);
133
+ return NULL;
134
+ }
132
135
  Py_RETURN_NONE;
133
136
  }
134
137
 
@@ -0,0 +1 @@
1
+ VERSION=1.5.4
@@ -1 +0,0 @@
1
- VERSION=1.5.3.dev2
File without changes
File without changes
File without changes
File without changes
File without changes