Changeset 4790:c1073581d7c2 in roaraudio
- Timestamp:
- 03/11/11 11:25:22 (13 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroar/memmgr.h
r4708 r4790 98 98 #define ROAR_MLOCK _ROAR_MLOCK 99 99 100 // aux functions: 101 void * roar_mm_memdup(const void * s, size_t len); 102 100 103 #endif 101 104 -
libroar/auth.c
r4788 r4790 133 133 char * header = mes.data; 134 134 int ret; 135 char * data = NULL; 135 136 136 137 memset(&mes, 0, sizeof(struct roar_message)); // make valgrind happy! … … 139 140 mes.datalen = 4 + authmes->len; 140 141 141 if ( mes.datalen > sizeof(mes.data) ) 142 return -1; 142 if ( mes.datalen > sizeof(mes.data) ) { 143 data = malloc(mes.datalen); 144 if ( data == NULL ) 145 return -1; 146 147 header = data; 148 } 143 149 144 150 header[0] = authmes->type; … … 148 154 149 155 if ( authmes->len ) { 150 memcpy(mes.data + 4, authmes->data, authmes->len); 151 } 152 153 if ( (ret = roar_req(con, &mes, NULL)) == -1 ) { 156 if ( data == NULL ) { 157 memcpy(mes.data + 4, authmes->data, authmes->len); 158 } else { 159 memcpy(data + 4, authmes->data, authmes->len); 160 } 161 } 162 163 if ( (ret = roar_req(con, &mes, &data)) == -1 ) { 154 164 authmes->type = -1; 155 165 return -1; 156 166 } 157 167 168 if ( data != NULL ) { 169 header = data; 170 } else { 171 header = mes.data; 172 } 173 158 174 if ( mes.cmd != ROAR_CMD_OK ) { 175 if ( data != NULL ) { 176 // we currently do not support long error frames. 177 free(data); 178 return -1; 179 } 180 159 181 ret = -1; 160 182 if ( roar_err_parsemsg(&mes, &error_frame) == -1 ) { … … 177 199 authmes->reserved.c[0] = header[2]; 178 200 authmes->reserved.c[1] = header[3]; 201 202 if ( data != NULL ) 203 free(data); 179 204 180 205 return ret; -
libroar/authfile.c
r4787 r4790 166 166 } 167 167 168 ret->data = ret + sizeof(struct roar_authfile_key) + addrlen;168 ret->data = (void*)ret + sizeof(struct roar_authfile_key) + addrlen; 169 169 170 170 ret->len = len; -
libroar/libroar.c
r4708 r4790 86 86 } 87 87 88 void * roar_mm_memdup(const void * s, size_t len) { 89 void * ret = roar_mm_malloc(len); 90 91 if ( ret == NULL ) 92 return NULL; 93 94 memcpy(ret, s, len); 95 96 return ret; 97 } 98 88 99 //ll -
roard/req.c
r4780 r4790 115 115 return -1; 116 116 117 ROAR_INFO("req_on_auth(client=%i,...): authtype=%s(%i) ", ROAR_DBG_INFO_VERBOSE,118 client, roar_autht2str(authmes.type), authmes.type );117 ROAR_INFO("req_on_auth(client=%i,...): authtype=%s(%i), len=%llu bytes", ROAR_DBG_INFO_VERBOSE, 118 client, roar_autht2str(authmes.type), authmes.type, (long long unsigned int)authmes.len); 119 119 120 120 ret = auth_client_ckeck(cs, &authmes, &next); -
roard/roard.c
r4789 r4790 1374 1374 struct roar_authfile_key * key = NULL; 1375 1375 int af_type = ROAR_AUTHFILE_TYPE_AUTO; 1376 void * keydata; 1376 1377 1377 1378 if ( type == NULL ) { … … 1428 1429 } 1429 1430 1430 if ( auth_addkey_cookie(acclev, key->data, key->len) == -1 ) { 1431 keydata = roar_mm_memdup(key->data, key->len); 1432 1433 if ( keydata == NULL ) { 1434 ROAR_WARN("add_authfile(*): Can not allocate memory for key."); 1435 } else if ( auth_addkey_cookie(acclev, keydata, key->len) == -1 ) { 1431 1436 ROAR_WARN("add_authfile(*): Can not add key to internal key storage."); 1432 1437 }
Note: See TracChangeset
for help on using the changeset viewer.