~ubuntu-branches/ubuntu/natty/mysql-5.1/natty-proposed

« back to all changes in this revision

Viewing changes to mysys/my_net.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 08:30:45 UTC
  • mfrom: (1.4.1)
  • Revision ID: package-import@ubuntu.com-20120222083045-2rd53r4bnyx7qus4
Tags: 5.1.61-0ubuntu0.11.04.1
* SECURITY UPDATE: Update to 5.1.61 to fix multiple security issues
  (LP: #937869)
  - http://www.oracle.com/technetwork/topics/security/cpujan2012-366304.html
  - CVE-2011-2262
  - CVE-2012-0075
  - CVE-2012-0112
  - CVE-2012-0113
  - CVE-2012-0114
  - CVE-2012-0115
  - CVE-2012-0116
  - CVE-2012-0117
  - CVE-2012-0118
  - CVE-2012-0119
  - CVE-2012-0120
  - CVE-2012-0484
  - CVE-2012-0485
  - CVE-2012-0486
  - CVE-2012-0487
  - CVE-2012-0488
  - CVE-2012-0489
  - CVE-2012-0490
  - CVE-2012-0491
  - CVE-2012-0492
  - CVE-2012-0493
  - CVE-2012-0494
  - CVE-2012-0495
  - CVE-2012-0496

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000 MySQL AB
 
1
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
2
2
 
3
3
   This program is free software; you can redistribute it and/or modify
4
4
   it under the terms of the GNU General Public License as published by
31
31
#include <arpa/inet.h>
32
32
#endif
33
33
#endif /* !defined(__WIN__) */
 
34
#include "my_net.h"
 
35
 
34
36
 
35
37
void my_inet_ntoa(struct in_addr in, char *buf)
36
38
{
40
42
  strmov(buf,ptr);
41
43
  pthread_mutex_unlock(&THR_LOCK_net);
42
44
}
 
45
 
 
46
/* This code is not needed if my_gethostbyname_r is a macro */
 
47
#if !defined(my_gethostbyname_r)
 
48
 
 
49
/*
 
50
  Emulate SOLARIS style calls, not because it's better, but just to make the
 
51
  usage of getbostbyname_r simpler.
 
52
*/
 
53
 
 
54
#if defined(HAVE_GETHOSTBYNAME_R)
 
55
 
 
56
#if defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
 
57
 
 
58
struct hostent *my_gethostbyname_r(const char *name,
 
59
                                   struct hostent *result, char *buffer,
 
60
                                   int buflen, int *h_errnop)
 
61
{
 
62
  struct hostent *hp;
 
63
  DBUG_ASSERT((size_t) buflen >= sizeof(*result));
 
64
  if (gethostbyname_r(name,result, buffer, (size_t) buflen, &hp, h_errnop))
 
65
    return 0;
 
66
  return hp;
 
67
}
 
68
 
 
69
#elif defined(HAVE_GETHOSTBYNAME_R_RETURN_INT)
 
70
 
 
71
struct hostent *my_gethostbyname_r(const char *name,
 
72
                                   struct hostent *result, char *buffer,
 
73
                                   int buflen, int *h_errnop)
 
74
{
 
75
  if (gethostbyname_r(name,result,(struct hostent_data *) buffer) == -1)
 
76
  {
 
77
    *h_errnop= errno;
 
78
    return 0;
 
79
  }
 
80
  return result;
 
81
}
 
82
 
 
83
#else
 
84
 
 
85
/* gethostbyname_r with similar interface as gethostbyname() */
 
86
 
 
87
struct hostent *my_gethostbyname_r(const char *name,
 
88
                                   struct hostent *result, char *buffer,
 
89
                                   int buflen, int *h_errnop)
 
90
{
 
91
  struct hostent *hp;
 
92
  DBUG_ASSERT(buflen >= sizeof(struct hostent_data));
 
93
  hp= gethostbyname_r(name,result,(struct hostent_data *) buffer);
 
94
  *h_errnop= errno;
 
95
  return hp;
 
96
}
 
97
#endif /* GLIBC2_STYLE_GETHOSTBYNAME_R */
 
98
 
 
99
#else /* !HAVE_GETHOSTBYNAME_R */
 
100
 
 
101
#ifdef THREAD
 
102
extern pthread_mutex_t LOCK_gethostbyname_r;
 
103
#endif
 
104
 
 
105
/*
 
106
  No gethostbyname_r() function exists.
 
107
  In this case we have to keep a mutex over the call to ensure that no
 
108
  other thread is going to reuse the internal memory.
 
109
 
 
110
  The user is responsible to call my_gethostbyname_r_free() when he
 
111
  is finished with the structure.
 
112
*/
 
113
 
 
114
struct hostent *
 
115
my_gethostbyname_r(const char *name,
 
116
                   struct hostent *result __attribute__((unused)), 
 
117
                   char *buffer __attribute__((unused)),
 
118
                   int buflen __attribute__((unused)), 
 
119
                   int *h_errnop)
 
120
{
 
121
  struct hostent *hp;
 
122
  pthread_mutex_lock(&LOCK_gethostbyname_r);
 
123
  hp= gethostbyname(name);
 
124
  *h_errnop= h_errno;
 
125
  return hp;
 
126
}
 
127
 
 
128
void my_gethostbyname_r_free()
 
129
{
 
130
  pthread_mutex_unlock(&LOCK_gethostbyname_r);  
 
131
}
 
132
 
 
133
#endif /* !HAVE_GETHOSTBYNAME_R */
 
134
#endif /* !my_gethostbyname_r */