Changeset 5146:716400712348 in roaraudio for libroar/auth.c
- Timestamp:
- 10/15/11 12:48:07 (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroar/auth.c
r5144 r5146 135 135 char * data = NULL; 136 136 137 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}) = ?", con, authmes, authmes->type); 138 139 roar_err_init(&error_frame); 137 140 memset(&mes, 0, sizeof(struct roar_message)); // make valgrind happy! 138 141 … … 162 165 } 163 166 164 if ( (ret = roar_req(con, &mes, &data)) == -1 ) { 167 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}) = ?", con, authmes, authmes->type); 168 169 if ( (ret = roar_req2(con, &mes, &data, &error_frame)) == -1 ) { 165 170 authmes->type = -1; 166 return -1; 167 } 171 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p) = -1 // next: -1", con, authmes, authmes->type); 172 return -1; 173 } 174 175 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}): mes->cmd=%i", con, authmes, authmes->type, mes.cmd); 168 176 169 177 if ( data != NULL ) { … … 173 181 } 174 182 175 if ( mes.cmd != ROAR_CMD_OK ) { 176 if ( data != NULL ) { 177 // we currently do not support long error frames. 178 free(data); 179 return -1; 180 } 181 183 if ( mes.cmd == ROAR_CMD_ERROR ) 182 184 ret = -1; 183 if ( roar_err_parsemsg(&mes, &error_frame) == -1 ) { 184 authmes->type = -1;185 return -1;186 } 187 185 186 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}): error_frame.data=%p", 187 con, authmes, authmes->type, error_frame.data); 188 189 if ( mes.cmd == ROAR_CMD_ERROR && error_frame.data != NULL ) { 188 190 header = error_frame.data; 189 191 mes.datalen = error_frame.datalen; 190 192 } 193 194 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}) = ?", con, authmes, authmes->type); 191 195 192 196 if ( mes.datalen < 4 ) { … … 197 201 } 198 202 203 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p) = ?", con, authmes); 204 199 205 authmes->stage = header[1]; 200 206 authmes->reserved.c[0] = header[2]; … … 204 210 free(data); 205 211 212 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p) = %i // next: %i", con, authmes, ret, authmes->type); 206 213 return ret; 207 214 } … … 307 314 for (i = 0; ltt[i] != _EOL; i++) { 308 315 next = ltt[i]; 316 ROAR_DBG("roar_auth(con=%p): next from ltt: %s(%i)", con, roar_autht2str(next), next); 317 309 318 while (next != -1) { 310 319 done = 1; … … 312 321 cur = next; 313 322 next = -1; 323 324 ROAR_DBG("roar_auth(con=%p): cur=%s(%i)", con, roar_autht2str(cur), cur); 314 325 315 326 switch (cur) { … … 322 333 case ROAR_AUTH_T_RHOST: 323 334 case ROAR_AUTH_T_NONE: 324 roar_auth_mes_init(&authmes, ltt[i]);335 roar_auth_mes_init(&authmes, cur); 325 336 if ( (ret = roar_auth_ask_server(con, &authmes)) == -1 ) 326 337 done = 0; … … 341 352 done = 0; 342 353 343 if ( done ) 354 ROAR_DBG("roar_auth(con=%p): done=%i, next=%i", con, done, next); 355 356 if ( done ) { 357 ROAR_DBG("roar_auth(con=%p) = 0", con); 344 358 return 0; 359 } 345 360 } 346 361 } 347 362 363 ROAR_DBG("roar_auth(con=%p) = -1", con); 348 364 return -1; 349 365 } … … 354 370 char header[4] = {0, 0, 0, 0}; 355 371 356 if ( ames == NULL || mes == NULL ) 357 return -1; 372 if ( ames == NULL || mes == NULL ) { 373 roar_err_set(ROAR_ERROR_FAULT); 374 return -1; 375 } 358 376 359 377 if ( data != NULL ) { … … 386 404 char * obuf; 387 405 388 if ( mes == NULL || ames == NULL ) 389 return -1; 406 if ( mes == NULL || ames == NULL ) { 407 roar_err_set(ROAR_ERROR_FAULT); 408 return -1; 409 } 390 410 391 411 if ( data != NULL )
Note: See TracChangeset
for help on using the changeset viewer.