History

crypto: consistently use size_t as type for length parameters

size_t is the correct type to use for sizes.

Diego Biurrun committed 9 years ago

Commit e435beb1 parent f1af37b6 files · +34 −4Browse files

Unified · Split

6 files
  1. doc/APIchanges +4 −0
  2. libavutil/md5.c +8 −0
  3. libavutil/md5.h +7 −1
  4. libavutil/sha.c +5 −1
  5. libavutil/sha.h +7 −2
  6. libavutil/version.h +3 −0
doc/APIchanges+4−0
@@ -13,6 +13,10 @@ libavutil: 2015-08-28 · 12 unmodified lines
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162016-xx-xx - xxxxxxx
17 Change av_sha_update() and av_md5_sum()/av_md5_update() length
18 parameter type to size_t at next major bump.
19
162016-xx-xx - xxxxxxx - lavc 57.29.0 - avcodec.h202016-xx-xx - xxxxxxx - lavc 57.29.0 - avcodec.h
17 Add AV_PKT_DATA_SPHERICAL packet side data to export AVSphericalMapping21 Add AV_PKT_DATA_SPHERICAL packet side data to export AVSphericalMapping
18 information from containers.22 information from containers.
libavutil/md5.c+8−0
@@ -146,7 +146,11 @@ void av_md5_init(AVMD5 *ctx) · 145 unmodified lines
146 ctx->ABCD[3] = 0x67452301;146 ctx->ABCD[3] = 0x67452301;
147}147}
148 148
149#if FF_API_CRYPTO_SIZE_T
149void av_md5_update(AVMD5 *ctx, const uint8_t *src, const int len)150void av_md5_update(AVMD5 *ctx, const uint8_t *src, const int len)
151#else
152void av_md5_update(AVMD5 *ctx, const uint8_t *src, size_t len)
153#endif
150{154{
151 int i, j;155 int i, j;
152 156
@@ -177,7 +181,11 @@ void av_md5_final(AVMD5 *ctx, uint8_t *dst) · 24 unmodified lines
177 AV_WL32(dst + 4 * i, ctx->ABCD[3 - i]);181 AV_WL32(dst + 4 * i, ctx->ABCD[3 - i]);
178}182}
179 183
184#if FF_API_CRYPTO_SIZE_T
180void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len)185void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len)
186#else
187void av_md5_sum(uint8_t *dst, const uint8_t *src, size_t len)
188#endif
181{189{
182 AVMD5 ctx;190 AVMD5 ctx;
183 191
libavutil/md5.h+7−1
@@ -21,6 +21,7 @@ · 20 unmodified lines
21#ifndef AVUTIL_MD5_H21#ifndef AVUTIL_MD5_H
22#define AVUTIL_MD5_H22#define AVUTIL_MD5_H
23 23
24#include <stddef.h>
24#include <stdint.h>25#include <stdint.h>
25 26
26#include "attributes.h"27#include "attributes.h"
@@ -36,9 +37,14 @@ struct AVMD5; · 9 unmodified lines
36 37
37struct AVMD5 *av_md5_alloc(void);38struct AVMD5 *av_md5_alloc(void);
38void av_md5_init(struct AVMD5 *ctx);39void av_md5_init(struct AVMD5 *ctx);
39void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len);
40void av_md5_final(struct AVMD5 *ctx, uint8_t *dst);40void av_md5_final(struct AVMD5 *ctx, uint8_t *dst);
41#if FF_API_CRYPTO_SIZE_T
42void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len);
41void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len);43void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len);
44#else
45void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, size_t len);
46void av_md5_sum(uint8_t *dst, const uint8_t *src, size_t len);
47#endif
42 48
43/**49/**
44 * @}50 * @}
libavutil/sha.c+5−1
@@ -290,7 +290,11 @@ av_cold int av_sha_init(AVSHA *ctx, int bits) · 289 unmodified lines
290 return 0;290 return 0;
291}291}
292 292
293void av_sha_update(AVSHA* ctx, const uint8_t* data, unsigned int len)293#if FF_API_CRYPTO_SIZE_T
294void av_sha_update(struct AVSHA *ctx, const uint8_t *data, unsigned int len)
295#else
296void av_sha_update(struct AVSHA *ctx, const uint8_t *data, size_t len)
297#endif
294{298{
295 unsigned int i, j;299 unsigned int i, j;
296 300
libavutil/sha.h+7−2
@@ -21,6 +21,7 @@ · 20 unmodified lines
21#ifndef AVUTIL_SHA_H21#ifndef AVUTIL_SHA_H
22#define AVUTIL_SHA_H22#define AVUTIL_SHA_H
23 23
24#include <stddef.h>
24#include <stdint.h>25#include <stdint.h>
25 26
26#include "attributes.h"27#include "attributes.h"
@@ -51,11 +52,15 @@ int av_sha_init(struct AVSHA* context, int bits); · 24 unmodified lines
51/**52/**
52 * Update hash value.53 * Update hash value.
53 *54 *
54 * @param context hash function context55 * @param ctx hash function context
55 * @param data input data to update hash with56 * @param data input data to update hash with
56 * @param len input data length57 * @param len input data length
57 */58 */
58void av_sha_update(struct AVSHA* context, const uint8_t* data, unsigned int len);59#if FF_API_CRYPTO_SIZE_T
60void av_sha_update(struct AVSHA *ctx, const uint8_t *data, unsigned int len);
61#else
62void av_sha_update(struct AVSHA *ctx, const uint8_t *data, size_t len);
63#endif
59 64
60/**65/**
61 * Finish hashing and output digest value.66 * Finish hashing and output digest value.
libavutil/version.h+3−0
@@ -105,6 +105,9 @@ · 104 unmodified lines
105#ifndef FF_API_PKT_PTS105#ifndef FF_API_PKT_PTS
106#define FF_API_PKT_PTS (LIBAVUTIL_VERSION_MAJOR < 56)106#define FF_API_PKT_PTS (LIBAVUTIL_VERSION_MAJOR < 56)
107#endif107#endif
108#ifndef FF_API_CRYPTO_SIZE_T
109#define FF_API_CRYPTO_SIZE_T (LIBAVUTIL_VERSION_MAJOR < 56)
110#endif
108 111
109 112
110/**113/**

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t