pkarashchenko commented on code in PR #1623: URL: https://github.com/apache/nuttx-apps/pull/1623#discussion_r1156052730
########## examples/ustream/ustream_server.c: ########## @@ -60,7 +60,7 @@ int main(int argc, FAR char *argv[]) /* Allocate a BIG buffer */ - buffer = (char*)malloc(2*SENDSIZE); + buffer = (char *)malloc(2*SENDSIZE); Review Comment: ```suggestion buffer = (char *)malloc(2 * SENDSIZE); ``` ########## netutils/xmlrpc/response.c: ########## @@ -203,50 +209,59 @@ int xmlrpc_buildresponse(struct xmlrpc_s *xmlcall, char *args, ...) { if ((args[index] != '{') && (args[index] != '}')) { - sprintf(&xmlcall->response[strlen(xmlcall->response)], - " <member>\n"); - sprintf(&xmlcall->response[strlen(xmlcall->response)], - " <name>%s</name>\n", va_arg(argp, char *)); + next += snprintf(&xmlcall->response[next], Review Comment: ditto ########## netutils/tftpc/tftpc_packets.c: ########## @@ -122,13 +122,13 @@ int tftp_sockinit(struct sockaddr_in *server, in_addr_t addr) * ****************************************************************************/ -int tftp_mkreqpacket(uint8_t *buffer, int opcode, const char *path, - bool binary) +int tftp_mkreqpacket(uint8_t *buffer, size_t len, int opcode, + const char *path, bool binary) { buffer[0] = opcode >> 8; buffer[1] = opcode & 0xff; - return sprintf((char *)&buffer[2], "%s%c%s", path, 0, - tftp_mode(binary)) + 3; + return snprintf((char *)&buffer[2], len - 2, "%s%c%s", path, 0, Review Comment: ditto. need to check return value before return to caller ########## netutils/ftpd/ftpd.c: ########## @@ -1470,16 +1471,18 @@ static FAR char *ftpd_node2path(FAR struct ftpd_pathnode_s *node, { if (namelen <= 0) { - allocsize += sprintf(&path[allocsize], "/"); + next += snprintf(&path[next], allocsize - next, "/"); Review Comment: general notice: we should not add `snprintf` result as: 1. it can be -1 2. it can be bigger than size passed as second parameter. ########## system/vi/vi.c: ########## @@ -1298,7 +1298,7 @@ static bool vi_savetext(FAR struct vi_s *vi, FAR const char *filename, fclose(stream); - len = sprintf(vi->scratch, "%dC written", nwritten); + len = snprintf(vi->scratch, sizeof(vi->scratch), "%dC written", nwritten); Review Comment: ditto ########## system/sched_note/note_main.c: ########## @@ -729,7 +729,8 @@ static void dump_notes(size_t nread) for (i = 0; i < count; i++) { - ret += sprintf(&out[ret], " 0x%x", note_binary->nbi_data[i]); + ret += snprintf(&out[ret], sizeof(out) - ret, Review Comment: ditto -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org