This file is indexed.

/usr/share/gsoap/plugin/httpmd5.c is in gsoap 2.8.16-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
/*

httpmd5.c

gSOAP HTTP Content-MD5 digest plugin.

Usage (both client and server, see httpmd5test.h/.c for example):
soap_register_plugin(&soap, http_md5);
This enables HTTP MD5 checksum generation and checking for SOAP/XML messages
WITHOUT attachments.

Compile with -DWITH_OPENSSL
Link with OpenSSL (for md5evp.c), httpmd5.c, and md5evp.c

gSOAP XML Web services tools
Copyright (C) 2000-2005, Robert van Engelen, Genivia Inc., All Rights Reserved.
This part of the software is released under one of the following licenses:
GPL, the gSOAP public license, or Genivia's license for commercial use.
--------------------------------------------------------------------------------
gSOAP public license.

The contents of this file are subject to the gSOAP Public License Version 1.3
(the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.cs.fsu.edu/~engelen/soaplicense.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.

The Initial Developer of the Original Code is Robert A. van Engelen.
Copyright (C) 2000-2005, Robert van Engelen, Genivia, Inc., All Rights Reserved.
--------------------------------------------------------------------------------
GPL license.

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA

Author contact information:
engelen@genivia.com / engelen@acm.org

This program is released under the GPL with the additional exemption that
compiling, linking, and/or using OpenSSL is allowed.
--------------------------------------------------------------------------------
A commercial use license is available from Genivia, Inc., contact@genivia.com
--------------------------------------------------------------------------------

	Requires an md5 engine, see md5evp.h

	int md5_handler(struct soap *soap, void **context, enum md5_action action, char *buf, size_t len)
	context can be set and passed to subsequent calls. Parameters:
	action =
	MD5_INIT:	init context
	MD5_UPDATE:	update context with data from buf with size len
	MD5_FINAL:	fill buf with 16 bytes MD5 hash value
	MD5_DELETE:	delete context
	buf		input data, output MD5 128 bit hash value
	len		length of input data

	Example code:
	httpmd5test.h, httpmd5test.c

	Limitations:
	Does not work with combined chunked + compressed messages.
	When sending DIME/MIME attachments, you MUST use the SOAP_IO_STORE flag
	to compute the MD5 hash of the message with attachments. The flag
	disables streaming DIME.
*/

#include "httpmd5.h"

#ifdef __cplusplus
extern "C" {
#endif

const char http_md5_id[13] = HTTP_MD5_ID;

static int http_md5_init(struct soap *soap, struct http_md5_data *data);
static int http_md5_copy(struct soap *soap, struct soap_plugin *dst, struct soap_plugin *src);
static void http_md5_delete(struct soap *soap, struct soap_plugin *p);

static int http_md5_post_header(struct soap *soap, const char *key, const char *val);
static int http_md5_parse_header(struct soap *soap, const char *key, const char *val);
static int http_md5_prepareinitsend(struct soap *soap);
static int http_md5_prepareinitrecv(struct soap *soap);
static int http_md5_preparesend(struct soap *soap, const char *buf, size_t len);
static int http_md5_preparerecv(struct soap *soap, const char *buf, size_t len);
static int http_md5_preparefinalrecv(struct soap *soap);

int http_md5(struct soap *soap, struct soap_plugin *p, void *arg)
{ p->id = http_md5_id;
  p->data = (void*)SOAP_MALLOC(soap, sizeof(struct http_md5_data));
  p->fcopy = http_md5_copy;
  p->fdelete = http_md5_delete;
  if (p->data)
    if (http_md5_init(soap, (struct http_md5_data*)p->data))
    { SOAP_FREE(soap, p->data); /* error: could not init */
      return SOAP_EOM; /* return error */
    }
  return SOAP_OK;
}

static int http_md5_init(struct soap *soap, struct http_md5_data *data)
{ data->fposthdr = soap->fposthdr;
  soap->fposthdr = http_md5_post_header;
  data->fparsehdr = soap->fparsehdr;
  soap->fparsehdr = http_md5_parse_header;
  data->fprepareinitsend = soap->fprepareinitsend;
  soap->fprepareinitsend = http_md5_prepareinitsend;
  data->fprepareinitrecv = soap->fprepareinitrecv;
  soap->fprepareinitrecv = http_md5_prepareinitrecv;
  data->fpreparesend = soap->fpreparesend;
  soap->fpreparesend = http_md5_preparesend;
  data->context = NULL;
  memset(data->digest, 0, sizeof(data->digest));
  return SOAP_OK;
}

static int http_md5_copy(struct soap *soap, struct soap_plugin *dst, struct soap_plugin *src)
{ *dst = *src;
  dst->data = (void*)SOAP_MALLOC(soap, sizeof(struct http_md5_data));
  memcpy(dst->data, src->data, sizeof(struct http_md5_data));
  ((struct http_md5_data*)dst->data)->context = NULL;
  return SOAP_OK;
}

static void http_md5_delete(struct soap *soap, struct soap_plugin *p)
{ struct http_md5_data *data = (struct http_md5_data*)soap_lookup_plugin(soap, http_md5_id);
  if (data)
  { md5_handler(soap, &data->context, MD5_DELETE, NULL, 0);
    SOAP_FREE(soap, data);
  }
}

static int http_md5_post_header(struct soap *soap, const char *key, const char *val)
{ struct http_md5_data *data = (struct http_md5_data*)soap_lookup_plugin(soap, http_md5_id);
  char buf64[25]; /* 24 base64 chars + '\0' */
  int err;
  if (!data)
    return SOAP_PLUGIN_ERROR;
  if (!key) /* last line */
  { if ((err = md5_handler(soap, &data->context, MD5_FINAL, data->digest, 0)))
      return err;
    data->fposthdr(soap, "Content-MD5", soap_s2base64(soap, (unsigned char*)data->digest, buf64, 16));
  }
  return data->fposthdr(soap, key, val);
}

static int http_md5_parse_header(struct soap *soap, const char *key, const char *val)
{ struct http_md5_data *data = (struct http_md5_data*)soap_lookup_plugin(soap, http_md5_id);
  if (!data)
    return SOAP_PLUGIN_ERROR;
  if (!soap_tag_cmp(key, "Content-MD5"))
  { soap_base642s(soap, val, data->digest, 16, NULL);
    data->fpreparerecv = soap->fpreparerecv;
    soap->fpreparerecv = http_md5_preparerecv;
    data->fpreparefinalrecv = soap->fpreparefinalrecv;
    soap->fpreparefinalrecv = http_md5_preparefinalrecv;
    md5_handler(soap, &data->context, MD5_INIT, NULL, 0);
    return SOAP_OK;
  }
  return data->fparsehdr(soap, key, val);
}

static int http_md5_prepareinitsend(struct soap *soap)
{ struct http_md5_data *data = (struct http_md5_data*)soap_lookup_plugin(soap, http_md5_id);
  if (!data)
    return SOAP_PLUGIN_ERROR;
  if ((soap->mode & SOAP_IO) != SOAP_IO_STORE && (soap->mode & (SOAP_ENC_DIME | SOAP_ENC_MIME)))
  { /* TODO: handle attachments automatically, does not work yet */
    soap->mode &= ~SOAP_IO;
    soap->mode |= SOAP_IO_STORE;
  }
  else
    md5_handler(soap, &data->context, MD5_INIT, NULL, 0);
  if (data->fprepareinitsend)
    return data->fprepareinitsend(soap);
  return SOAP_OK;
}

static int http_md5_prepareinitrecv(struct soap *soap)
{ struct http_md5_data *data = (struct http_md5_data*)soap_lookup_plugin(soap, http_md5_id);
  if (!data)
    return SOAP_PLUGIN_ERROR;
  if (soap->fpreparerecv == http_md5_preparerecv)
    soap->fpreparerecv = data->fpreparerecv;
  if (soap->fpreparefinalrecv == http_md5_preparefinalrecv)
    soap->fpreparefinalrecv = data->fpreparefinalrecv;
  if (data->fprepareinitrecv)
    return data->fprepareinitrecv(soap);
  return SOAP_OK;
}

static int http_md5_preparesend(struct soap *soap, const char *buf, size_t len)
{ struct http_md5_data *data = (struct http_md5_data*)soap_lookup_plugin(soap, http_md5_id);
  if (!data)
    return SOAP_PLUGIN_ERROR;
  md5_handler(soap, &data->context, MD5_UPDATE, (char*)buf, len);
  if (data->fpreparesend)
    return data->fpreparesend(soap, buf, len);
  return SOAP_OK;
}

static int http_md5_preparerecv(struct soap *soap, const char *buf, size_t len)
{ struct http_md5_data *data = (struct http_md5_data*)soap_lookup_plugin(soap, http_md5_id);
  if (!data)
    return SOAP_PLUGIN_ERROR;
  md5_handler(soap, &data->context, MD5_UPDATE, (char*)buf, len);
  if (data->fpreparerecv)
    return data->fpreparerecv(soap, buf, len);
  return SOAP_OK;
}

static int http_md5_preparefinalrecv(struct soap *soap)
{ struct http_md5_data *data = (struct http_md5_data*)soap_lookup_plugin(soap, http_md5_id);
  char digest[16];
  if (!data)
    return SOAP_PLUGIN_ERROR;
  md5_handler(soap, &data->context, MD5_FINAL, digest, 0);
  soap->fpreparerecv = data->fpreparerecv;
  soap->fpreparefinalrecv = data->fpreparefinalrecv;
  if (memcmp(digest, data->digest, 16))
    return soap_sender_fault(soap, "MD5 digest mismatch: message corrupted", NULL);
  if (soap->fpreparefinalrecv)
    return soap->fpreparefinalrecv(soap);
  return SOAP_OK;
}

#ifdef __cplusplus
}
#endif