@@ -54,7 +54,7 @@ int tac_acct_parse(struct tac_session *sess, u_char *pkt, unsigned pkt_total,
54
54
55
55
ulen_from_header = ntohl (th -> datalength );
56
56
57
- tb = ( struct acct_reply * )( pkt + TAC_PLUS_HDR_SIZE );
57
+ tb = tac_hdr_to_body ( th );
58
58
59
59
if (pkt_total != ulen_from_header ) {
60
60
TACSYSLOG (LOG_ERR ,\
@@ -88,14 +88,14 @@ int tac_acct_parse(struct tac_session *sess, u_char *pkt, unsigned pkt_total,
88
88
89
89
/* save status and clean up */
90
90
if (tb -> msg_len ) {
91
- msg = ( char * ) xcalloc (1 , tb -> msg_len + 1 );
91
+ msg = xcalloc (1 , tb -> msg_len + 1 );
92
92
bcopy ((u_char * ) tb + TAC_ACCT_REPLY_FIXED_FIELDS_SIZE , msg , tb -> msg_len );
93
93
msg [tb -> msg_len ] = '\0' ;
94
94
re -> msg = msg ; /* Freed by caller */
95
95
}
96
96
97
97
if (tb -> data_len ) {
98
- msg = ( char * ) xcalloc (1 , tb -> data_len + 1 );
98
+ msg = xcalloc (1 , tb -> data_len + 1 );
99
99
bcopy ((u_char * ) tb + TAC_ACCT_REPLY_FIXED_FIELDS_SIZE + tb -> data_len ,
100
100
msg , tb -> data_len );
101
101
msg [tb -> data_len ] = '\0' ;
@@ -156,9 +156,9 @@ int tac_acct_read(struct tac_session *sess, struct areply *re) {
156
156
return re -> status ;
157
157
}
158
158
159
- th = ( HDR * ) xcalloc (1 , TAC_PLUS_HDR_SIZE );
159
+ th = xcalloc (1 , TAC_PLUS_HDR_SIZE );
160
160
161
- spacket_read = read (sess -> fd , ( char * ) th , TAC_PLUS_HDR_SIZE );
161
+ spacket_read = read (sess -> fd , th , TAC_PLUS_HDR_SIZE );
162
162
if (spacket_read < TAC_PLUS_HDR_SIZE ) {
163
163
TACSYSLOG (LOG_ERR ,\
164
164
"%s: short reply header, read %zd of %u expected: %m" , __FUNCTION__ ,\
@@ -181,8 +181,8 @@ int tac_acct_read(struct tac_session *sess, struct areply *re) {
181
181
}
182
182
183
183
/* now make room for entire contiguous packet */
184
- th = ( HDR * ) xrealloc (th , TAC_PLUS_HDR_SIZE + ulen_from_header );
185
- tb = ( struct acct_reply * )(( u_char * ) th + TAC_PLUS_HDR_SIZE );
184
+ th = xrealloc (th , TAC_PLUS_HDR_SIZE + ulen_from_header );
185
+ tb = tac_hdr_to_body ( th );
186
186
187
187
/* read reply packet body */
188
188
if (tac_readtimeout_enable &&
@@ -195,7 +195,7 @@ int tac_acct_read(struct tac_session *sess, struct areply *re) {
195
195
return re -> status ;
196
196
}
197
197
198
- spacket_read = read (sess -> fd , ( char * ) tb , ulen_from_header );
198
+ spacket_read = read (sess -> fd , tb , ulen_from_header );
199
199
if (spacket_read < 0 || (size_t ) spacket_read < ulen_from_header ) {
200
200
TACSYSLOG (LOG_ERR ,\
201
201
"%s: short reply body, read %zd of %zu: %m" ,\
@@ -208,7 +208,8 @@ int tac_acct_read(struct tac_session *sess, struct areply *re) {
208
208
}
209
209
210
210
/* now parse remaining packet fields */
211
- status = tac_acct_parse (sess , (u_char * )th , TAC_PLUS_HDR_SIZE + ulen_from_header , re );
211
+ status = tac_acct_parse (sess , (u_char * )th ,
212
+ TAC_PLUS_HDR_SIZE + ulen_from_header , re );
212
213
213
214
/* all useful data has been copied out */
214
215
free (th );
0 commit comments