|
Lines 284-293
add_local_forward(Options *options, const struct Forward *newfwd)
Link Here
|
| 284 |
{ |
286 |
{ |
| 285 |
struct Forward *fwd; |
287 |
struct Forward *fwd; |
| 286 |
extern uid_t original_real_uid; |
288 |
extern uid_t original_real_uid; |
|
|
289 |
int i; |
| 287 |
|
290 |
|
| 288 |
if (newfwd->listen_port < IPPORT_RESERVED && original_real_uid != 0 && |
291 |
if (newfwd->listen_port < IPPORT_RESERVED && original_real_uid != 0 && |
| 289 |
newfwd->listen_path == NULL) |
292 |
newfwd->listen_path == NULL) |
| 290 |
fatal("Privileged ports can only be forwarded by root."); |
293 |
fatal("Privileged ports can only be forwarded by root."); |
|
|
294 |
/* Don't add duplicates */ |
| 295 |
for (i = 0; i < options->num_local_forwards; i++) { |
| 296 |
if (forward_equals(newfwd, options->local_forwards + i)) |
| 297 |
return; |
| 298 |
} |
| 291 |
options->local_forwards = xreallocarray(options->local_forwards, |
299 |
options->local_forwards = xreallocarray(options->local_forwards, |
| 292 |
options->num_local_forwards + 1, |
300 |
options->num_local_forwards + 1, |
| 293 |
sizeof(*options->local_forwards)); |
301 |
sizeof(*options->local_forwards)); |
|
Lines 310-316
void
Link Here
|
| 310 |
add_remote_forward(Options *options, const struct Forward *newfwd) |
318 |
add_remote_forward(Options *options, const struct Forward *newfwd) |
| 311 |
{ |
319 |
{ |
| 312 |
struct Forward *fwd; |
320 |
struct Forward *fwd; |
|
|
321 |
int i; |
| 313 |
|
322 |
|
|
|
323 |
/* Don't add duplicates */ |
| 324 |
for (i = 0; i < options->num_remote_forwards; i++) { |
| 325 |
if (forward_equals(newfwd, options->remote_forwards + i)) |
| 326 |
return; |
| 327 |
} |
| 314 |
options->remote_forwards = xreallocarray(options->remote_forwards, |
328 |
options->remote_forwards = xreallocarray(options->remote_forwards, |
| 315 |
options->num_remote_forwards + 1, |
329 |
options->num_remote_forwards + 1, |
| 316 |
sizeof(*options->remote_forwards)); |
330 |
sizeof(*options->remote_forwards)); |